I try to make a barplot of a time-series dataset with ggplot2
but I get following error message (I have performed this on a similar dataset and it works):
Error in if (!is.null(data$ymin) && !all(data$ymin == 0)) warning("Stacking not well defined when ymin != 0", : missing value where TRUE/FALSE needed
For this I have used following code:
p <- ggplot(dataset, aes(x=date, y=value)) + geom_bar(stat="identity")
If I use geom_point()
instead of geom_bar()
it works fine.
You haven't provided a reproducible example, so I'm just guessing, but your syntax doesn't look right to me. Check here: http://docs.ggplot2.org/current/geom_bar.html
Bar charts by default produce tabulations of counts:
p <- ggplot( dataset, aes( factor(date) ) ) + geom_bar()
If you want it to do something different, you'll need to tell it what statistic to use. See the link above (towards the bottom) for an example using the mean. Alternatively, see here for a hybrid point/scatterplot (very bottom of the page): http://docs.ggplot2.org/current/position_jitter.html
But fundamentally you have two continuous variables and it's not clear to me why you'd want anything but a scatterplot.
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.