berkeley <- aggregate(wtable(Admit,Freq)~.,data=UCBAdmissions)
Transform(berkeley,
list(total=sum(Admitted) + sum(Rejected)),
Admitted.p = Admitted/total,
Rejected.p = Rejected/total)
Transform(berkeley,
{ total <- sum(Admitted) + sum(Rejected)
list(total=total)
},
Admitted.p = Admitted/total,
Rejected.p = Rejected/total)
Run the code above in your browser using DataLab