0

I am Having a little problem doing a Levene test in R. I does not get any output value, only NaN. Anyone know what the problem might be?

Have used the code:

with(Test,levene.test(Sample1,Sample2,location="median"))

The problem

Best regards

  • 2
    Don't post pictures of data. See [how to create a reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). This will make it easier to help you. Also explicitly list any packages you are using. `levene.test()` is not a function in base R. – MrFlick Mar 27 '17 at 19:56

1 Answers1

0

The levene.test function assumes the data are in a single vector. The second argument is a grouping variable.

Concatenate your data using the c() function: data=c(Sample1, Sample2). Construct a vector of group names like gp = rep('Gp1','Gp2', each=240). Then, call the function as follows: levene.test(data, gp, location='median').

This can also be done directly:

levene.test(c(Sample1, Sample2), rep('Gp1', 'Gp2', each=240)), location='median')
Edward Carney
  • 1,372
  • 9
  • 7
  • probably should be `rep(c('Gp1','Gp2'), each=240)` wouldn't it ? Because `rep('Gp1', 'Gp2', each=240)` returns an error. – matthieu Oct 08 '20 at 22:55