简体   繁体   English

使用ggplot的R中的Barplot错误

[英]Barplot Error in R using ggplot

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): 我尝试使用ggplot2制作时间序列数据集的ggplot2但是我收到了以下错误消息(我在类似的数据集上执行了此操作并且它有效):

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. 如果我使用geom_point()而不是geom_bar()它可以正常工作。

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 点击此处: 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 或者,请参阅此处查看混合点/散点图(页面底部): 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. 但从根本上说,你有两个连续的变量,我不清楚为什么你想要除了散点图之外的任何东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM