R中数据帧的正态性测试

时间:2017-11-25 19:15:02

标签: r dataframe normal-distribution

我正在对两列两个数据帧进行一些正态性测试:

# Normality tests

shapiro.test(male$height)
shapiro.test(female$height)

ad.test(male$height)
ad.test(female$height)

cvm.test(male$height)
cvm.test(female$height)

lillie.test(male$height)
lillie.test(female$height)

pearson.test(male$height)
pearson.test(female$height)

sf.test(male$height)
sf.test(female$height)

但这对我来说效率非常低。我尝试使用tapply并应用函数但我无法使其工作。有什么猜测吗?

1 个答案:

答案 0 :(得分:0)

您可以尝试使用lapply

lapply(list(male, female), function(x) {

 list(shapiro.test(x$height),
      ad.test(x$height),
      cvm.test(x$height),
      lillie.test(x$height),
      pearson.test(x$height),
      sf.test(x$height))

})