I am running a kruskal.test
on some non-normal data with the agricolae
package. Some groups have exactly the same value as each other. The kruskal
test doesn't handle this well, I receive the error Error in if (s) { : missing value where TRUE/FALSE needed
. At first, I thought this was because all the values were 0, but when I make them all the same large number (to test), the same error appears and the function will stop
(running function through a loop) and doesn't evaluate anything beyond the first tied variable.
Obviously there is no point running stats on these groups as there will be no difference, but I am using the information generated by agricolae:kruskal
to produce a summary table and I need these variables included. I would prefer to keep using this package as it gives me a lot of valuable information. Is there anything I can do to make it run through the tied variables?
dput(example)
structure(list(TREATMENT = c("A", "A", "A", "B", "B", "C", "C",
"C", "D", "D"), W = c(0, 1.6941524646937, 1.524431531984, 0.959282869723864,
1.45273122733115, 0, 1.57479386520925, 0.421759202661462, 1.34235435984449,
1.52131484305823), X = c(0, 0.663872820198758, 0.202935807030853,
0.836223346381214, 0.750767193777965, 1.18128574225979, 2.03622986392828,
3.56466682539425, 0.919751117364462, 0.917347336682722), Y = c(0,
0, 0, 0, 0, 0, 0, 0, 0, 0), Z = c(2.1477548118197, 2.0111754022729,
3.14642815196242, 4.46967452127494, 1.53715421615569, 2.36274861406182,
2.33262528044302, 2.50970456594739, 2.96088598025103, 2.22841740590261
)), class = "data.frame", row.names = c(NA, 10L), .Names = c("TREATMENT",
"W", "X", "Y", "Z"))
library(agricolae)
example<-as.data.frame(example)
for(i in 2:(ncol(example))){
krusk <- kruskal(example[,i],TREATMENT,group=TRUE)
print(krusk)
}
for(i in 2:(ncol(example))){
if(var(example[,i]) > 0){
krusk <- kruskal(example[,i],example$TREATMENT,group=TRUE)
print(krusk)
}
}