MSchwartz at medanalytics.com
Tue Aug 12 22:39:18 CEST 2003
On Tue, 2003-08-12 at 15:03, Gerhard Prade wrote:
> Hello all,
> i think i am to silly. I have installed R 1.7.1 (2003-06-16). Installed
> some packages like xtables ore xml. I tried out this to installing
> packages. Then i tried to make a crosstable like i know it from spss.
> They say in this list that it would be going.
> I made a table in asci-format, seperated with tabs or blanks and than i
> use something like this:
> ok. that works.
> than i want make a crosstables with the first and the second variable.
> i tried ftable with something like that:
> ftable(soz, col.vars = 1:2)
> For me it is a quiz what the corect syntax for this is.
> I want get something like this:
> Question 1.1
> What is your age?
> PC-User Linux-User Windows-User
> 0-10 Years 10% 10 20% 20 30% 30
> 10-20 Years 50% 50 70% 70 40% 40
> over 20 Years 40% 40 10% 10 30% 30
> Summary 100% 100 100% 100 100% 100
> Can anybody help and send me a example for the correct way and the
> syntax i must use to get this? I dont understand the manual, because the
> ways from r is very different to spss-syntax, i think.
> Thanks, Gerhard
To generate a table similar to the above [actually closer to SAS' PROC
Freq and S-Plus' crosstabs()], use the CrossTable() function in the
'gregmisc' package on CRAN.
Once you have installed 'gregmisc' and have loaded the library [using
"library(gregmisc)"], you can then use "?CrossTable" to display the help
for the function with example code so that you can get a feel for the
format of the output and associated options.
The basic syntax for use would be:
where Var1 will be the rows and Var2 will be the columns.
If you have further questions on the use of CrossTable(), let me know.
Best regards and welcome to R,
More information about the R-help