I am wondering if anyone can tell me what the error I'm receiving means below. I thought it said that Aeventexhumed should be converted to a factor, so I tried to do so and received the following error. Please advise. J ---------------------------------------------------------> data.to.analyze.glm <- glm(cbind(MaxHatch, TotalEggs-MaxHatch) ~ > Aeventexhumed, family=binomial, data=data.to.analyze)Warning message: In model.matrix.default(mt, mf, contrasts) : variable 'Aeventexhumed' converted to a factor> data.to.analyze$Aevent ~ as.factor(data.to.analyze$Aevent)data.to.analyze$Aevent ~ as.factor(data.to.analyze$Aevent)> data.to.analyze$Aeventexhumed <- as.factor(data.to.analyze$Aevent)Error in `$<-.data.frame`(`*tmp*`, "Aeventexhumed", value = integer(0)) : replacement has 0 rows, data has 127> summary(data.to.analyze$Aeventexhumed)Length Class Mode 127 character character -- View this message in context: http://r.789695.n4.nabble.com/Error-in-variable-converted-to-a-factor-AND-tmp-tp4305951p4305951.html Sent from the R help mailing list archive at Nabble.com.
Milan Bouchet-Valat
2012-Jan-18 10:50 UTC
[R] Error in variable ' _' converted to a factor AND *tmp*
Le mardi 17 janvier 2012 ? 23:56 -0800, Jhope a ?crit :> I am wondering if anyone can tell me what the error I'm receiving means > below. I thought it said that Aeventexhumed should be converted to a factor, > so I tried to do so and received the following error. > > Please advise. J > --------------------------------------------------------- > > > data.to.analyze.glm <- glm(cbind(MaxHatch, TotalEggs-MaxHatch) ~ > > Aeventexhumed, family=binomial, data=data.to.analyze) > Warning message: > In model.matrix.default(mt, mf, contrasts) : > variable 'Aeventexhumed' converted to a factor > > > data.to.analyze$Aevent ~ as.factor(data.to.analyze$Aevent) > data.to.analyze$Aevent ~ as.factor(data.to.analyze$Aevent)What is this supposed to do? You're just creating a formula and printing it here.> > data.to.analyze$Aeventexhumed <- as.factor(data.to.analyze$Aevent) > Error in `$<-.data.frame`(`*tmp*`, "Aeventexhumed", value = integer(0)) : > replacement has 0 rows, data has 127This simply means that data.to.analyze$Aeventexhumed is of length 127, while data.to.analyze$Aevent is of length 0 (or most probably doesn't exist). I think you meant to do: data.to.analyze$Aeventexhumed <- factor(data.to.analyze$Aeventexhumed) Regards