I have three variables which are factors: stimulus (12 levels), match (2 levels and Listgp (3 levels: T, TA and TQ). I already split the Listgp (Listener group) into three subset dataframes as follows.
mydata1T <-mydata[mydata$Listgp == "T", ]
mydata1TA <-mydata[mydata$Listgp == "TA", ]
mydata1TQ <-mydata[mydata$Listgp == "TQ", ]
Then I cross tabulated stimulusXmatch
for each of the groups and even plotted them using barplot()
and everything works just fine. However, when I try to use boxplot() in the lattice package, I get the error
(Error in boxplot.default(split(mf[[response]], mf[-response]), ...)
adding class "factor" to an invalid object).
The syntax I used is as follows.
par(mfrow=c(1,3))
boxplot(mydata1T$stimulus~mydata1T$match, data=mydata)
boxplot(mydata1TA$stimulus~mydata1TA$match, data=mydata)
boxplot(mydata1TA$stimulus~mydata1TQ$match, data=mydata)
par(mfrow=c(1,1))
How can I solve this problem and create three boxplots for the three group of listeners?