Problem with nor.test function in R. Sample size must be between 3 and 5000

180 Views Asked by At

I have a problem using the nor.test function as a oneway test in R. My data contain yield value (Rdt_pied) that are grouped by treatment (Traitement). In each treatment I have between 60 and 90 values.

> describe(Rdt_pied ~ Traitement, data = dataMax) 

      n     Mean  Std.Dev Median Min  Max   25th    75th  Skewness Kurtosis NA
G(1) 90 565.0222 282.1874  535.0  91 1440 379.00  751.25 0.7364071 3.727566  0
G(2) 90 703.1444 366.1114  632.5 126 1628 431.50 1007.75 0.4606251 2.392356  0
G(3) 90 723.9667 523.5872  650.5  64 2882 293.50 1028.50 1.2606231 5.365014  0
G(4) 90 954.1000 537.0138  834.5  83 2792 565.25 1143.75 1.1695460 4.672321  0
G(A) 60 368.0667 218.1940  326.0  99 1240 243.00  420.00 2.2207612 9.234473  0
G(H) 60 265.4667 148.0383  223.5 107  866 148.00  357.25 1.3759925 5.685456  0
G(S) 60 498.8000 280.1277  401.0 170 1700 292.75  617.50 1.6792061 7.125804  0
G(T) 60 521.7167 374.7822  448.5  74 1560 214.00  733.25 1.1367209 3.737134  0
>  

Why do the nor.test returns me this answer?

> nor.test(Rdt_pied ~ Traitement, data = dataMax) 

Error in shapiro.test(y[which(group == (levels(group)[i]))]) : 
  sample size must be between 3 and 5000

Thank you for your help!

1

There are 1 best solutions below

2
On

Haven't used that package, but per documentation (and your error), nor.test performs Shapiro-Wilk normality test by default, which needs a numeric vector as an input (at least 3 values). My guess is that, there is a group, based on Traitement, which has less than 3 values, or more than 5000. Try to check it with something like

table(dataMax$Traitement)