[R] time series from timed data
Gabor Grothendieck
ggrothendieck at gmail.com
Wed Mar 23 00:01:48 CET 2011
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
More information about the R-help
mailing list