# create simulated data, no population mean difference
# X has two values only, Y is numeric
# put into a data frame
n <- 12
X <- sample(c("Group1","Group2","Group3"), size=n, replace=TRUE)
Y <- round(rnorm(n=n, mean=50, sd=10), 2)
mydata <- data.frame(X,Y)
# analyze data with formula version
# variable names and levels of X are automatically obtained from data
# although data frame not attached, reference variable names directly
ANOVA(Y ~ X)
# short name
av(Y ~ X)
# variable of interest is in a data frame which is not the default mydata
# access the data frame in the lessR dat.twogroup data set
# although data not attached, access the variables directly by their name
data(dataGroups2)
ANOVA(ShipTime ~ Supplier, dframe=dataGroups2)
# two-factor between-groups ANOVA with replications and interaction
ANOVA(breaks ~ wool * tension, dframe=warpbreaks)
# randomized blocks design with the second term the blocking factor
ANOVA(breaks ~ wool + tension, dframe=warpbreaks)
Run the code above in your browser using DataLab