[R] Contingency tables example

VictorDelgado victor.maia at fjp.mg.gov.br
Thu Dec 29 15:20:01 CET 2011


sambooth21 wrote
> 
> I am having a few problems importing the data i'm running this code and
> the table sets up fine but all of the data values say NA:
> 
> housdat<- c(21, 21, 28, 14, 19, 37, 34, 22, 36, 17, 23, 401, 10, 11, 36,
> 3, 5, 23, 61, 23, 17, 78, 46, 43, 43, 35, 40, 48, 45, 86, 26, 18, 54, 15,
> 25, 62)
> housdat<-array(dim=c(2,3,6))
> dimnames(housdat) <- list(Housing=c("Tower Block","Apartment"),
> Influence=c("Low","Medium","High"),
> ContactSatisfaction=c("LCLow","LCMed","LCHigh","HCLow","HCMed","HCHigh"))
> 
> ftable(housdat, row.vars=c("Housing","Influence"),
> col.vars="ContactSatisfaction")
> 
> any advice would be greatly appreciated!
> 

Try this:

housdat<-array(housdat,dim=c(2,3,6))

Pay attention to some values that do you have inserted. Maybe you can fix it
using:

fix(housdat)

-----
Victor Delgado
cedeplar.ufmg.br P.H.D. student
www.fjp.mg.gov.br reseacher
--
View this message in context: http://r.789695.n4.nabble.com/Contingency-tables-example-tp4240145p4242873.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list