I have a data set having a value and a group, e.g.,
Val Grp
123 "A"
231 "A"
132 "A"
234 "A"
445 "B"
345 "B"
235 "B"
345 "B"
(The original dataset would be too large to show here.)
When I now do kruskal.test(data$Val, data$Grp)
, I get an error saying all group levels must be finite.
When I check the data with is.finite()
, I can see that all values are indeed finite.
The internet does not yield a lot of information on this error, so I have hope that someone could shed light on what this error means and what the problem could be.
It should work if you run
data$Grp <- as.factor(data$Grp)
Then (as before):
kruskal.test(data$Val, data$Grp)
This is because Grp
is a character not a factor and is.finite
applied to an object of character class is always false (see ?is.finite
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With