总共 36 列。
数据示例代码:
df <-
structure(
list(
Bacteroidaceae = c(
0,
0.10944999,
0.104713314,
0.125727668,
0.124136247,
0.005155911,
0.005072778,
0.010231826,
0.010188139
),
Christensenellaceae = c(
0,
0.009910731,
0.010131195,
0.009679938,
0.01147601,
0.010484508,
0.008641566,
0.010017172,
0.010741488
),
treatment = c(
"Original Sample1",
"Original Sample2",
"Original Sample3",
"Original Sample4",
"treatment1_1",
"treatment1_2",
"treatment1_3",
"treatment1_4"
)
),
class = "data.frame",
row.names = c(NA,-8L)
)
我想做的是为数据中的所有列创建图,因此每列将有 2 个图:一个用于处理 1,一个用于原始样本,总共 72 个图
例如:
我尝试使用此代码的原始样本类型相同:
df %>%
tidyr::pivot_longer(!treatment, names_to = "taxa", values_to = "value") %>%
dplyr::filter(str_detect(treatment, "Treatment1")) %>%
for (i in columns(df)){
)
ggplot(aes(x = treatment, y = value, color = taxa),group=treatment) +
geom_point() +
stat_summary(fun.y = mean,
geom = "line", width = 0.5)+geom_jitter(widh=0.25)
theme_bw()}}
但它没有用。还有其他方法吗?
谢谢你