[R] ggplot2 and Date class

Matt Frost mwfrost at gmail.com
Mon Jun 1 19:20:26 CEST 2009


I'm trying to plot a time series in ggplot, but a date column in my
data frame is causing errors. Rather than provide my own data, I'll
just refer to the scale_date example at:
http://had.co.nz/ggplot2/scale_date.html
, which reproduces the error.

> df <- data.frame( date = seq(Sys.Date(), len=100, by="1 day")[sample(100, 50)], price = runif(50) )
> dt <- qplot(date, price, data=df, geom="line") + opts(aspect.ratio = 1/4)
> dt + scale_x_date()

Error in aesdefaults(data, .$geom$default_aes(), compact(.$mapping)) :
could not find function "as_df"

My ggplot2 package is up to date. Am I missing something else, maybe
in my default aesthetics?

Thanks,
Matt Frost




More information about the R-help mailing list