作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用 geom_blank
我想添加一些新的因子水平,但我似乎无法这样做并保留 NA
水平
library('ggplot2')
pl <- ggplot(data.frame(x = factor(c(1:2, NA)), y = 1), aes(x, y)) + geom_point()
pl
pl + geom_blank(data = data.frame(x = addNA(factor(c(0:3, NA))), y = 1))
geom_blank
将 x 设为 0,1,2,3,NA
最佳答案
正如我在评论中所希望的那样,如果绘图已经完成,解决方法可能是重新排序图层,这通常适用于 ggplots。
library('ggplot2')
pl <- ggplot(data.frame(x = factor(c(1:2, NA)), y = 1), aes(x, y)) +
geom_point() +
geom_blank(data = data.frame(x = addNA(factor(c(0:3, NA))), y = 1))
## not what I want
pl
## this is what I want
pl$layers <- rev(pl$layers)
pl
关于r - geom_blank 丢弃 NA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39648451/
使用 geom_blank我想添加一些新的因子水平,但我似乎无法这样做并保留 NA水平 library('ggplot2') pl <- ggplot(data.frame(x = factor(c(
我是一名优秀的程序员,十分优秀!