![](/img/trans.png)
[英]How do you plot multiple columns of a data frame all within the same boxplot in r (using ggplot2)?
[英]Boxplot of multiple columns in `R` using ggplot
我只是想在R
中创建一个包含 dataframe 的三个数字列的箱线图。 dataframe 看起来像这样:
no_filter filter1 filter2
1 0.7223437 0.7376562 0.7418750
2 0.7223437 0.7376562 0.7418750
3 0.7262500 0.7276562 0.7289062
我在这里查看了How to create one box plot using multiple columns and argument "split" ,但我并没有真正理解它。 因此,如果有人有想法,将不胜感激。 在最好的情况下使用gpplot
使用ggplot
,我们可能需要重塑为“长”格式
library(dplyr)
library(tidyr)
df1 %>%
pivot_longer(cols = everything()) %>%
ggplot(aes(x = name, y = value)) +
geom_boxplot()
###数据
df1 <- structure(list(no_filter = c(0.7223437, 0.7223437, 0.72625),
filter1 = c(0.7376562, 0.7376562, 0.7276562), filter2 = c(0.741875,
0.741875, 0.7289062)), class = "data.frame", row.names = c("1",
"2", "3"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.