R语言分组进行正态性检验

2019-05-25  本文已影响0人  Whuer_deng
方法一:tapply
with(iris,tapply(Sepal.Length, Species, shapiro.test)) #方法一
$setosa

    Shapiro-Wilk normality test

data:  X[[i]]
W = 0.9777, p-value = 0.4595


$versicolor

    Shapiro-Wilk normality test

data:  X[[i]]
W = 0.97784, p-value = 0.4647


$virginica

    Shapiro-Wilk normality test

data:  X[[i]]
W = 0.97118, p-value = 0.2583
方法二:with
 with(iris,by(Sepal.Length, Species, shapiro.test)) #方法二
Species: setosa

    Shapiro-Wilk normality test

data:  dd[x, ]
W = 0.9777, p-value = 0.4595

---------------------------------------------------------- 
Species: versicolor

    Shapiro-Wilk normality test

data:  dd[x, ]
W = 0.97784, p-value = 0.4647

---------------------------------------------------------- 
Species: virginica

    Shapiro-Wilk normality test

data:  dd[x, ]
W = 0.97118, p-value = 0.2583
上一篇下一篇

猜你喜欢

热点阅读