[R] table () for more variables
Marc Schwartz
marc_schwartz at me.com
Sat Jul 4 16:26:17 CEST 2009
On Jul 3, 2009, at 12:10 PM, John Lipkins wrote:
> Dear All,
>
> I want to create a table for several variables. As example. I have a
> dataframe with following data:
>
> Gender transport driving
> 1 0 1
> 0 1 0
> 1 0 1
>
> Now I want to create a table in the following form:
>
> Gender
> 1 0
> Transport 1 2 0
> 0 0 1
> Driving 1 2 0
> 0 0 1
>
> In which the different percentages are being calculated (row/
> column). I have
> tried using ftable() but did not give the desired result (There are
> a lot of
> variables and the format makes it impossible to interpret).
>
> Is there anyone who can help me with this problem?
>
> Thanks in advance.
> Kind regards,
>
> John
John,
Take a look at the 'catspec' package by John Hendrickx on CRAN. There
is a function in there called 'ctab', which if memory is correct, will
do what you want. John had originally posted his code here:
https://stat.ethz.ch/pipermail/r-help/2003-February/030400.html
and it has been updated to some extent in the package since then.
HTH,
Marc Schwartz
More information about the R-help
mailing list