r-如何在dabestr中创建绘图循环?
我正在使用dabestr绘制估算图,对于单个变量,我成功了,但我想用for循环创建一批图,但它不起作用r-如何在dabestr中创建绘图循环?,r,loops,for-loop,plot,R,Loops,For Loop,Plot,我正在使用dabestr绘制估算图,对于单个变量,我成功了,但我想用for循环创建一批图,但它不起作用 library(dabestr) plot(dabest(iris, Species, Petal.Width, idx = c("setosa", "versicolor"), paired = FALSE)) 我想在for循环中绘制萼片。长度,萼片。宽度,花瓣。长度,花瓣。宽度。 有人帮忙吗?谢谢大家! 问题不在于for语句,而在于dabest函数。它被设置为只接受.data中给定的列
library(dabestr)
plot(dabest(iris, Species, Petal.Width, idx = c("setosa", "versicolor"), paired = FALSE))
我想在for循环中绘制萼片。长度,萼片。宽度,花瓣。长度,花瓣。宽度。
有人帮忙吗?谢谢大家! 问题不在于for语句,而在于
dabest
函数。它被设置为只接受.data
中给定的列名,因此带有列名的字符串不起作用
经过一番挖掘,我发现对于变量名的dplyr
相关问题非常有用
library(dabestr)
library(ggpubr) # for ggarrange
to_plot <- c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")
plots <- lapply(to_plot, function(co){
plot(dabest(iris, Species, UQ(rlang::sym(co)), idx = c("setosa", "versicolor"), paired = FALSE))
})
ggarrange(plotlist = plots, nrow = 2, ncol = 2)
库(dabestr)
图书馆(ggpubr)#供ggpubr使用
绘制dplyr相关函数可能会在自动操作/fors/lapplys等情况下表现出不可预测的行为。如果将来有其他问题,请随时查看类似问题。