On Sun, Oct 11, 2009 at 4:54 PM, romunov <romu...@gmail.com> wrote: > Dear List, > > I'm having problem with an exercise from The R book (M.J. Crawley) on page > 567. > Here is the entire code upto the point where I get an error. > > data(UCBAdmissions) > x <- aperm(UCBAdmissions, c(2, 1, 3)) > names(dimnames(x)) <- c("Sex", "Admit?", "Department") > ftable(x) > fourfoldplot(x, margin = 2) > dept<-gl(6,4) > sex<-gl(2,1,24) > admit<-gl(2,2,24) > model1<-glm(as.vector(x) ~dept*sex*admit,poisson) > > This last line returns: > > Error in family$family : $ operator is invalid for atomic vectors > > I've searched older posts but found nothing that would help resolve my > problem. Has anyone encountered anything similar and/or knows a fix? >
Works for me: > model1<-glm(as.vector(x) ~dept*sex*admit,poisson) > model1 Call: glm(formula = as.vector(x) ~ dept * sex * admit, family = poisson) Coefficients: (Intercept) dept2 dept3 dept4 6.23832 -0.37186 -1.45083 -1.31107 [etc] What's your version: > version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 9.2 year 2009 month 08 day 24 svn rev 49384 language R version.string R version 2.9.2 (2009-08-24) Barry ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.