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: soz<-read.table("/home/user/test.txt") 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) or 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
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: > > soz<-read.table("/home/user/test.txt") > > 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) > > or > > 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, GerhardTo 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: CrossTable(Var1, Var2) 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, Marc Schwartz
On Tue, 12 Aug 2003, Gerhard Prade wrote:> 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. > > than i want make a crosstables with the first and the second variable.I'm not sure what SPSS does as I have never used it. But is the CrossTable() function in the gregmisc library what you want? -- Cheers, Kevin ------------------------------------------------------------------------------ "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." -- Charles Babbage (1791-1871) ---- From Computer Stupidities: http://rinkworks.com/stupid/ -- Ko-Kang Kevin Wang Master of Science (MSc) Student SLC Tutor and Lab Demonstrator Department of Statistics University of Auckland New Zealand Homepage: http://www.stat.auckland.ac.nz/~kwan022 Ph: 373-7599 x88475 (City) x88480 (Tamaki)