Reputation: 793
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.
Upvotes: 0
Views: 1558
Reputation: 72779
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.
Upvotes: 2