【发布时间】:2020-08-17 00:28:51
【问题描述】:
variance_homo<-function(df,col1,col2){
if (is.numeric(df[,col2]) & nlevels(df[,col1])>2){
bartlett_res<-bartlett.test(col2~col1,df,na.action=na.omit)
leven_res<-leveneTest(col2,col1,data=df,na.action=na.omit)
}
return(bartlett_res)
}
上面的脚本是一个简单的函数,当我运行它时,出现如下错误:
> variance_homo(iris,'Species','Sepal.Length')
Error in bartlett.test.default("Sepal.Length", "Species") :
all observations are in the same group
Called from: bartlett.test.default("Sepal.Length", "Species")
有什么问题??
【问题讨论】:
标签: r