简体   繁体   English

如何在R中的数据帧上使用Levene检验

[英]How to use Levene's test on a data frame in R

Say I have a data frame with two columns, height (in inches) and sex (Male or Female) and I want to run levene's test to see if the variance is the same for Male and Female height. 假设我有一个包含两列的数据框,高度(以英寸为单位)和性别(男性或女性),并且我想运行levene的测试以查看男性和女性身高的方差是否相同。 How would I do this? 我该怎么做?

I've read a few other questions here but none of them seem to address running a test from a data frame. 我在这里阅读了其他一些问题,但似乎都没有解决从数据帧运行测试的问题。

It's actually very easy. 实际上非常简单。 Assuming your data is in data and the columns are height and sex : 假设您的数据在data ,列为heightsex

# load leveneTest function
library(car)
# run the levene test centered around the mean
leveneTest(data$height, data$sex, center=mean)

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

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