Charles Raux wrote:
> Hello,
> I would like to transform a contingency table (A x B) into a data 
> frame while keeping the cross-tabulation structure (i.e. rows = 
> levels of A, columns = levels of B). I have tried as.data.frame, 
> xtabs, etc... and always got a "flattened" list of 3 variables (A, B, 
> Freq).
> How to do that?
> Thanks in advance
> Charles Raux
> 

How about:

x <- table(state.division, state.region)
as.data.frame(array(x, dim(x), dimnames(x)))

HTH,

--sundar

--sundar

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to