Re: [R] making zoo objects with zoo without format argument?

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Tue, 08 Jul 2008 14:55:28 -0400

On Tue, Jul 8, 2008 at 2:43 PM, Gabor Grothendieck <ggrothendieck_at_gmail.com> wrote:
> There is no data in your data frame, just index info, so I assume you
> want a zero width time series:
>
> zoo(, as.yearmon(x$Yearmonth, "%Y-%m"))
>
> This also works but then you are left with a character date which you
> may not want:
>
> zoo(, x$Yearmonth)

This last one should have been:

zoo(, as.character(x$Yearmon))

since your data frame holds a factor rather than character column.

>
>
> On Tue, Jul 8, 2008 at 1:43 PM, stephen sefick <ssefick@gmail.com> wrote:
>> #this is a subset of a larger data frame and I am okay with subsetting it as
>> there are redundant time stamps, but I would like to create a zoo object out
>> of this and I am having a hard #time figuring out how to do this the date
>> structure is year and then month
>>
>> x <- structure(list(Yearmonth = structure(c(12L, 24L, 1L, 13L, 14L,
>> 3L, 15L, 4L, 16L, 5L, 17L, 6L, 18L, 7L, 19L, 8L, 20L, 9L, 21L,
>> 10L, 22L, 11L, 23L), .Label = c("2006-02", "2006-03", "2006-04",
>> "2006-05", "2006-06", "2006-07", "2006-08", "2006-09", "2006-10",
>> "2006-11", "2006-12", "2007-01", "2007-02", "2007-03", "2007-04",
>> "2007-05", "2007-06", "2007-07", "2007-08", "2007-09", "2007-10",
>> "2007-11", "2007-12", "2008-01"), class = "factor"), Month = c(1L,
>> 1L, 2L, 2L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 8L, 9L, 9L,
>> 10L, 10L, 11L, 11L, 12L, 12L)), .Names = c("Yearmonth", "Month"
>> ), class = "data.frame", row.names = c(NA, 23L))
>>
>> #thanks Stephen
>>
>> --
>> Let's not spend our time and resources thinking about things that are so
>> little or so large that all they really do for us is puff us up and make us
>> feel like gods. We are mammals, and have not exhausted the annoying little
>> problems of being mammals.
>>
>> -K. Mullis
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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 Tue 08 Jul 2008 - 18:59:47 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 08 Jul 2008 - 20:33:30 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