Hello!
I am trying to run a 3 way mixed model anova using my data (Sex x PCB x Day_2) and the lme4 package.
This was my initial code:
Pref_df <- read_xlsx("~/Documents/D_DSacBotStat.xlsx", sheet = "Pref")
MMA_D2 <- lmer(Pref_df$Day_2 ~ PCB Treat* Sex + 1|id, data = D_DSacBotStat )
Error in model.frame.default(data = D_DSacBotStat, drop.unused.levels = TRUE, :
variable lengths differ (found for 'PCB Treat')
So I adjusted the file and changed the name to PCB_treatment and had this code:
MMA_D2 <- lmer(Pref_df$Day_2 ~ Pref_df$PCB_Treatment * Pref_df$Sex + 1|id, data = D_DSacBotStat )
But I was met with this error:
Error in model.frame.default(data = D_DSacBotStat, drop.unused.levels = TRUE, :
invalid type (closure) for variable 'id'
This is the portion of the data I am trying to use (image attached)
Also I am fairly new to R, although I cannot seem to figure out what 1 | id means in the code and if that could be the source of the problem because maybe I am not using it correctly as it invalid type (closure) for variable id?
Any help would be greatly appreciated!
Thank you!