[R] Help with CrossTable
Dieter Menne
dieter.menne at menne-biomed.de
Wed Oct 1 09:35:04 CEST 2008
Ravi S. Shankar <ravis <at> ambaresearch.com> writes:
>
> I am using the CrossTable function from library(gmodels).
>
> x=unique(data[,c("L1","L1_Revenues","RIC")])
>
> L1_Classification=CrossTable(x$L1,x$L1_Revenues,exclude =
> c("NA","","0%","0"),prop.r=FALSE,prop.c=FALSE,prop.t=FALSE,prop.chisq=FA
> LSE,dnn=c("L1_Classification","Revenue"))
>
> What I would like to do is to get the out put in excel. Also I do not
> want the output displayed on the console. Is there some way of doing
> this?
gmodels' CrossTable is not very flexible for this, because it has hard-wired cat
producing the output. Try to massage ftable:
ft = ftable(mtcars$cyl, mtcars$vs, mtcars$am, mtcars$gear)
write.csv(ft, file = "ft.csv") # see docs how to
Also check package Hmisc and reshape (the latter is not very flexible for
categorical data, but good for numeric).
Dieter
More information about the R-help
mailing list