Hi All,
There seems to be a problem with date_breaks, I ran the example code and following error is displayed. Could you please help me.
# dataset ‘economics’ from ggplot2 ver 0.9.0
> qp = qplot(date, psavert/100, data = economics, geom = "line") + labs(x = "Year", y = "Personal savings rate")
> qp + scale_x_date(breaks = date_breaks("5 years"),labels = date_format("%Y"))
Error in scale_date(c("x", "xmin", "xmax", "xend"), expand = expand, breaks = breaks, :
could not find function "date_breaks"
even similar error is displayed for “date_format” function.
> sessionInfo()
R version 2.14.2 (2012-02-29)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_0.9.0
loaded via a namespace (and not attached):
[1] colorspace_1.1-1 dichromat_1.2-4 digest_0.5.1 grid_2.14.2
[5] MASS_7.3-17 memoise_0.1 munsell_0.3 plyr_1.7.1
[9] proto_0.3-9.2 RColorBrewer_1.0-5 reshape2_1.2.1 scales_0.2.0
[13] stringr_0.6 tools_2.14.2
Thanks for the help,
Regards,
S.N.V. Krishna
It is in the scales package, so:
require(ggplot2)
require(scales)
qplot(date, psavert/100, data = economics, geom = "line") +
labs(x = "Year", y = "Personal savings rate") +
scale_x_date(breaks = date_breaks("5 years"),labels = date_format("%Y"))
should do the trick.
Cheers,
Josh
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
--
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/
S.N.V. Krishna
One of the differences in ggplot2-0.9.0 relative to 0.8.9 and earlier
is that other packages are no longer autoloaded with ggplot2; for
example, plyr and reshape are no longer 'co-loaded'. Moreover,
formatting and labeling functions that used to be in ggplot2-0.8.9
have been moved into the scales package along with a large number of
transformation functions, so if you intend to modify your positional
guides (axes) through transformation or axis label formatting, or
modify strip labels with a labeling function, you should load the
scales package along with ggplot2. It is probably not a bad idea to
write a custom .Rprofile function that loads a set of packages at
startup if you use them routinely in your work.
Dennis
Good point. Also, you may find the transition guide to 0.9
(spearheaded by Dennis) useful:
http://cloud.github.com/downloads/hadley/ggplot2/guide-col.pdf
many examples you find online (or in Hadley Wickham's ggplot2 book)
may not work exactly the same in 0.9. The guide is helpful for
understanding how to adapt to the new, better world (better world of
software implementations of the grammar of graphics, that is).