I want to conduct a two-way ANOVA using r. I have four columns: Case (1-356), ab_all (my IV), appeal (with 3 levels) and product (with 2 levels). Unfortunately I always receive an error warning:

"$ operator is invalid for atomic vectors".

I know that I need to convert my data into a recursive object. But everything I tried failed.
Do you know how to solve the issue?

I already tried <- data.frame() as.data.frame(mydata)

str(mainstudy_category)
'data.frame':   356 obs. of  4 variables:
 $ CASE   : int  1 2 3 4 5 6 7 8 9 10 ...
 $ ab_all : num  5 5 5 5 4.4 3.2 4.2 2.8 3.8 5 ...
 $ appeal : Factor w/ 3 levels "emotional negative",..: 2 2 1 2 3 3 3 3 3 1 ...
 $ product: Factor w/ 2 levels "hedonic","utilitarian": 1 1 1 2 1 1 1 1 2 2 ...
model_category<-lm(ab_all~product*appeal, data=mainstudy_category)
anova(model_category, type="III")

Error: $ operator is invalid for atomic vectors

My Data:

structure(list(CASE = 1:6, ab_all = c(5, 5, 5, 5, 4.4, 3.2), appeal = structure(c(2L, 2L, 1L, 2L, 3L, 3L), .Label = c("emotional negative", "emotional positive", "rational"), class = "factor"), product = structure(c(1L, 1L, 1L, 2L, 1L, 1L), .Label = c("hedonic", "utilitarian"), class = "factor")), row.names = c(NA, 6L), class = "data.frame")

0 Answers