R ggplot aes输入是函数输入
我有我的功能R ggplot aes输入是函数输入,r,ggplot2,R,Ggplot2,我有我的功能 library(ggplot2) library(ggpubr) test<-function(k){ df1<-data.frame(matrix(runif(48,min = 1,max = 100),ncol = 2,dimnames = list(1:24,c("Apple","Banana")))) df1$Group1<-c("A","B")
library(ggplot2)
library(ggpubr)
test<-function(k){
df1<-data.frame(matrix(runif(48,min = 1,max = 100),ncol = 2,dimnames = list(1:24,c("Apple","Banana"))))
df1$Group1<-c("A","B")
df1$Group2<-c("o","o","o","p","p","p","q","q","q","r","r","r")
p<-ggplot(df1,
aes(x=Group2,
color=Group1))+
geom_boxplot(aes_string(y=k))+
stat_compare_means(aes(group=Group1))
p
}
a<-c("Apple")
test(a)
库(ggplot2)
图书馆(ggpubr)
由于某些原因,testI无法安装ggpubr
。这将是stat\u compare\u means
没有传入y
,例如这项工作stat\u compare\u means(aes\u字符串(group=“Group1”,x=“Group2”,y=k))
?可能不需要添加x
。您可以在基本ggplot中使用此aes_字符串
,然后就不用担心restYes了!多谢各位