Ah, thanks always - 
I originally thought as.chron() was required to have all fields (m/d/y 
hh:mm:ss) as for chron() but I see that the former passes its 'format' argument 
to  as.POSIXct()
Good deal!
Stephen



----- Original Message ----
From: Gabor Grothendieck <ggrothendi...@gmail.com>
To: Stephen Tucker <brown_...@yahoo.com>
Cc: Tony Breyal <tony.bre...@googlemail.com>; r-help@r-project.org
Sent: Thursday, August 27, 2009 7:27:26 AM
Subject: Re: [R] Merge data frames but with a twist.

On Thu, Aug 27, 2009 at 9:55 AM, Stephen Tucker<brown_...@yahoo.com> wrote:
> You may want to use the reshape package for this task:
>
>> library(reshape)
>> recast(DF3,Show ~ Datetime, id.var=names(DF3),value="Measure")
>       Show 08/26/2009 11:30 AM 08/26/2009 9:30 AM
> 1   Firefly                   3                  1
> 2 Red Dwarf                   4                  2
>
> If you want to plot time series, you can do something like the following
>
>> mydf <- .Last.value ## save the output from above to mydf
>> library(zoo)
>> zobj <- zoo(`mode<-`(t(mydf),"numeric"),
>>             as.chron(strptime(names(mydf)[-1],"%m/%d/%Y %I:%M %p")))
>> plot(zobj)
>
> (zobj is a time series object of the zoo class)

Note that as.chron can take % codes directly so the as.chron portion
can be shortened to:

as.chron(names(mydf)[-1],"%m/%d/%Y %I:%M %p")

______________________________________________
R-help@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.

Reply via email to