也许答案是要警告.我正在使用缩放和居中的变量来观察观察结果与平均值的差异.这个情节是一种常见的做法.但是当我这样做时,我会收到警告ggplot2.
Warning messages:
1: Stacking not well defined when ymin != 0
Run Code Online (Sandbox Code Playgroud)
我喜欢让ggplot2和世界其他地方高兴,没有任何警告来到我的路上.我试图通过以下方式摆脱警告,并搜索相关问题的SO(请参阅底部的链接以获得一些更有希望的问题).我的朋友ggplot2仍在警告我.
问题(S):
代码尝试:
## The data
mtcars$scaled_mpg <- unlist(tapply(mtcars$mpg, mtcars$cyl, scale))
mtcars <- mtcars[order(mtcars$cyl), ]
mtcars$ID <- unlist(tapply(mtcars$cyl, mtcars$cyl, seq_along))
mtcars$ID <- factor(sprintf("%02d", mtcars$ID ))
## ================ Attempt 1 ================
ggplot(mtcars, aes(x = ID, y = scaled_mpg, fill = factor(cyl))) +
geom_bar(stat="identity") + facet_grid(cyl~.)
## ================ Attempt 2 ================
ggplot(mtcars, aes(x = ID, fill = factor(cyl))) +
geom_bar(aes(weight = scaled_mpg)) + facet_grid(cyl~.)
## …Run Code Online (Sandbox Code Playgroud)