Using Levene’s Test for Equality of Variances

Installing the “lawstat” Package

The “lawstat” package is installed to utilize the tools provided by “lawstat”.
The tools are taught into R Studio through the library() command.

install.packages("lawstat")
library(lawstat)

Tidy the Data to Fit Format of Levene’s Test

The data must be tidy so that there is only one column with the factor and another with the responses.

dat3<-InsectSprays %>% filter(spray==c("A"."B"))

Levene’s Test

Levene’s Test evaluates the equality of variances.
y is the response, group is the factor, and location is the method of testing.
location=“mean” will have the data tested by the difference between group means and the overall mean.

levene.test(dat3$count,dat3$spray,location="mean")