Re: [R] [R[ dates on zoo objects

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Thu, 10 Jun 2010 10:33:10 -0400

or

> or # 3
> aggregate(z, as.Date(time(z), "%m/%d/%y"))
2009-04-16 2009-04-17

         1 2

On Thu, Jun 10, 2010 at 9:58 AM, Gabor Grothendieck <ggrothendieck_at_gmail.com> wrote:
> Its best to use dput when displaying your data in r-help as in dput(z)
> or dput(head(z)) if large.
>
> Try this:
>
>> library(zoo)
>> # test data
>> z <- zoo(1:2, factor(c("04/16/09","04/17/09")))
>>
>> # 1
>> aggregate(z, function(x) as.Date(x, "%m/%d/%y"))

> 2009-04-16 2009-04-17
>         1          2
>>
>> # or #2
>> time(z) <- as.Date(time(z), "%m/%d/%y")
>> z
> 2009-04-16 2009-04-17

>         1          2
>
> On Thu, Jun 10, 2010 at 9:42 AM, Erin Hodgess <erinm.hodgess_at_gmail.com> wrote:
>> Dear R People:
>>
>> I have a zoo object with its date index as a factor.
>>
>>> xAle1.zoo$index
>> Error in xAle1.zoo$index : $ operator is invalid for atomic vectors
>>> str(xAle1.zoo)
>> Class 'zoo'  atomic [1:32] 1253 1316 1038 1157 1710 1489 1159 1142 945 1245 ...
>>  ..- attr(*, "index")= Factor w/ 32 levels "04/16/09","04/17/09",..:
>> 1 2 3 4 5 6 7 8 9 10 ...
>>>
>>
>>
>>
>> How do I change that over to dates, please?
>>
>> Thanks,
>> Erin
>>
>>
>> --
>> Erin Hodgess
>> Associate Professor
>> Department of Computer and Mathematical Sciences
>> University of Houston - Downtown
>> mailto: erinm.hodgess_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.
>>
>



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 Thu 10 Jun 2010 - 14:38:40 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 Thu 10 Jun 2010 - 14:40:29 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