Re: [R] time series from timed data

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Tue, 22 Mar 2011 19:01:48 -0400

On Tue, Mar 22, 2011 at 6:49 PM, Sam Steingold <sds_at_gnu.org> wrote:
> Hi,
> thanks for your reply.
>
>> * Gabor Grothendieck <ttebguraqvrpx_at_tznvy.pbz> [2011-03-18 17:51:03 -0400]:
>> On Fri, Mar 18, 2011 at 2:19 PM, Sam Steingold <sds_at_gnu.org> wrote:
>>
>> 2. An alternative that won't generate a warning message but involves a
>> double read is:
>>
>> library(zoo)
>> toPOSIXct <- function(x) as.POSIXct(trunc(as.POSIXct(x), "sec"))
>> z <- read.zoo(textConnection(Lines), FUN = toPOSIXct, sep =
>> ",",  aggregate = mean)
>> zl <- read.zoo(textConnection(Lines), FUN = toPOSIXct, sep = ",",
>> aggregate = length)
>> cbind(z, count = zl[,1])
>>
>> In all cases replace textConnection(Lines) with the "myfile.csv" or whatever.
>
> is it possible to avoid both double read and warning?

(1) You could read the file line by line, (2) you could pipe it through gawk, (3) you could read it into sqlite using sqldf or RSQLite and then extract out the portion you want.

> I tried to pass a data frame to read.zoo and got
>
> Error in function (x)  :
>  unused argument(s) (sec = c(24.7736890316010, 27.7369959354401, 27.7369959354401, 28.8604519367218, 29.1779129505157, 30.0554060935974, 30.30619597435, 30.3425068855286, 30.5043799877167, 30.5294759273529, 31.567528963089, 31.5929388999939, 31.6186139583588, 31.670196056366, 31.7729399204254, 31.873172044754, 31.9950220584869, 32.4294190406799, 32.5335929393768, 32.8650600910187, 32.8651750087738, 32.8945369720459, 32.8971579074860, 32.8987069129944, 33.6954081058502, 33.7132570743561, 33.9529790878296, 33.9542989730835,
>
>  apparently in the call to toPOSIXct
>

Would need something reproducible.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 22 Mar 2011 - 23:09:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 22 Mar 2011 - 23:40:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive