berkeley <- aggregate(wtable(Admit,Freq)~.,data=UCBAdmissions)
By(~Dept,glm(cbind(Admitted,Rejected)~Gender,family="binomial"),data=berkeley)
attach(berkeley)
By(~Dept,glm(cbind(Admitted,Rejected)~Gender,family="binomial"))
detach(berkeley)
Run the code above in your browser using DataLab