Its a bug in axis.zoo. I have just fixed it in the svn repository so try this:
source("http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/pkg/R/yearmon.R?rev=485&root=zoo") plot(x.zoo[, 25]) axis.zoo uses the same algorithm as axis.Date in R and so it gives similar results: # uses axis.Date plot(aggregate(x.zoo[, 25], as.Date, force)) You may wish to try a custom axis: plot(x.zoo[, 25], xaxt = "n") rng <- range(time(x.zoo)) axis(1, at = seq(rng[1], rng[2], 1/12), labels = FALSE, tcl = -0.3) axis(1, at = seq(floor(rng[1]), floor(rng[2]))) On Tue, Jul 8, 2008 at 3:34 PM, stephen sefick <[EMAIL PROTECTED]> wrote: > That worked fine- now one more question- > plot(x.zoo[,25]) > produces a graph with True as the first label on the x-axis > 1. why? > 2. is it wrong to assume this is february 2006? > > thanks > > stephen > R2.7.1 Windows XP (I updated zoo last week when I installed 2.7.1) > > On Tue, Jul 8, 2008 at 3:17 PM, Gabor Grothendieck <[EMAIL PROTECTED]> > wrote: >> >> On Tue, Jul 8, 2008 at 2:59 PM, stephen sefick <[EMAIL PROTECTED]> wrote: >> > x.zoo <- zoo(x,as.yearmon(as.character(x$Yearmonth), "%Y-%m")) >> > plot(x.zoo[,25]) >> >> >> 1. You are trying to pass data frame to zoo whereas it must be a numeric >> vector, >> matrix or a factor. See ?zoo and try this: >> >> x.zoo <- zoo(data.matrix(x), as.yearmon(x$Yearmonth, format = "%Y-%m")) >> >> 2. You don't need as.character (it won't hurt but its unnecessary) since >> as.yearmon has a factor method. You only need as.character in the >> situation cited in the last post. >> >> >> > >> > #Error in plot.window(...) : invalid 'ylim' value >> > #there are values >> > >> > On Tue, Jul 8, 2008 at 2:55 PM, Gabor Grothendieck >> > <[EMAIL PROTECTED]> >> > wrote: >> >> >> >> On Tue, Jul 8, 2008 at 2:43 PM, Gabor Grothendieck >> >> <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> >> >> > 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@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. >> >> >> >> >> > >> > >> > >> > >> > -- >> > 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 > > > > -- > 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 ______________________________________________ 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.