简体   繁体   English

R-对两个不同尺寸的样品进行乙炔测试

[英]R - Perform a levene test with two samples with different sizes

So lets say that I have these two arrays with different sizes 所以可以说我有这两个大小不同的数组

值

And I'd like to perform a levene test with the function leveneTest() 我想用leveneTest()函数执行levene测试

However, the way I have been taught converts these to a dataframe and then calls the function melt to make a data structure readable by the function. 但是,我所教的方法将这些转换为数据帧,然后调用函数melt使数据结构可被该函数读取。 This ends up repopulating the smallest array so that both arrays have the same size. 这样最终会重新填充最小的数组,以便两个数组具有相同的大小。

dataServers <- as.data.frame(cbind(down25,down27)) #dataServers is 124*2 now
dataServers <- melt(dataServers,variable.name="Server",value.name="DownTimes")
leveneTest(DownTimes~Server,dataServers,center=mean)

What would be the easiest way around this? 解决这个问题的最简单方法是什么?

You can simply stack your two samples, of different sizes, into one data frame and perform the leveneTest : 您可以将两个不同大小的样本简单地stack到一个数据帧中,然后执行leveneTest

stacked <- stack(list(down25=down25,down27=down27))
car::leveneTest(values~ind,data=stacked,center=mean)

Could you not just make them independent dataframes add an identifier column to each and then do an R bind and run the test? 您不仅可以让它们独立的数据帧添加一个标识符列,然后进行R绑定并运行测试吗? I can make up a full example if that helps that is reproducible. 我可以举一个完整的例子,如果这样做可以重现。

make dataframe1 with id and value dataframe2 with id and value rbind the two together and skip the melt step 将id和value分别为dataframe1和rbbin为id和value的数据框2一起跳过跳过步骤

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM