使用 ggplot 绘制 `R` 中多列的箱线图
Boxplot of multiple columns in `R` using ggplot
我只是想在 R
中创建数据框的三个数字列的箱线图。数据框如下所示:
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
,我们可能需要重新整形为'long'格式
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"))
我只是想在 R
中创建数据框的三个数字列的箱线图。数据框如下所示:
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
,我们可能需要重新整形为'long'格式
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"))