I have a dataframe df
with a column time
which contains R date objects and I want to plot a density plot to see which days had the most activity. I don't want to convert to timestamps, because I would prefer more meaningful labels in the x-axis.
My attempt
Here is what I am trying:
ggplot(df, aes(x = time)) + geom_density(stat="identity") + scale_x_date()
which gives the error
Error in as.environment(where) : 'where' is missing
Here is the output of dput(df)
:
structure(list(time = structure(c(15863, 15887, 15865, 15873, 15885, 15878), class = "Date")), .Names = "time", row.names = 8831395:8831400, class = "data.frame")
For some reason the argument to stat_density is causing ggplot to lose its way among the environments that get set up. (At least that's where the "where" missing error comes from.) This succeeds:
ggplot(df, aes(x = time)) + geom_density()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.