mutant.p53.df<-data.frame( mutation=as.factor( rep(c("GC->TA","AT->GC","GC->AT","GC->CG","AT->TA"),rep(3,5))), cancer=as.factor(rep(c("SCLC","NSCLC","Colon"),5), count=c(6,16,0,4,0,3,1,5,14,1,4,1,0,2,1)) levels(mutant.p53.df$mutation)<- c("GC->TA","AT->GC","GC->AT","GC->CG","AT->TA") levels(mutant.p53.df$cancer) <-c("SCLC","NSCLC","Colon") mutant.tab<-crosstabs(count~mutation+cancer,data=mutant.p53.df) crosstabs(count ~ mutation + cancer, data = mutant.p53.df) mutation|cancer |SCLC |NSCLC |Colon |RowTotl| -------+-------+-------+-------+-------+ GC->TA | 3 | 0 | 4 |7 | -------+-------+-------+-------+-------+ AT->GC | 1 | 2 | 0 |3 | -------+-------+-------+-------+-------+ GC->AT |14 | 5 | 1 |20 | -------+-------+-------+-------+-------+ GC->CG | 1 | 4 | 1 |6 | -------+-------+-------+-------+-------+ AT->TA | 0 |16 | 6 |22 | -------+-------+-------+-------+-------+ ColTotl|19 |27 |12 |58 | -------+-------+-------+-------+-------+ Test for independence of all factors Chi^2 = 33.64526 d.f.= 8 (p=4.710024e-05) Yates' correction not used Some expected values are less than 5, don't trust stated p-value