hi, i'm new in R and i need some help. Please, ¿do you know a function how can process cross tables for many variables and show the result in one table who look like this?: +----------------------------------------------------+ |------------------ | X variable | |----------------- | Xop1 | Xop2 | Xop3|.....| +----------------------------------------------------+ |Yvar1 | Total | %row..........................| | | Op1 | %row..........................| | | Op2 | %row..........................| |+---------------------------------------------------+ |Yvar2 | Op1 | %row..........................| | | Op2 | %row...........................| +----------------------------------------------------+ |Yvar3 | Op1 | %row..........................| | | Op2 | %row...........................| | | Op3 | %row...........................| |+---------------------------------------------------+ Like a pivot table! thanks a lot. -- Jonathan. [[alternative HTML version deleted]]
On Sep 8, 2010, at 6:40 PM, Jonathan Finlay wrote:> hi, i'm new in R and i need some help. Please, ?do you know a > function how > can process cross tables for many variables and show the result in > one table > who look like this?: > > +----------------------------------------------------+ > |------------------ | X variable | > |----------------- | Xop1 | Xop2 | Xop3|.....| > +----------------------------------------------------+ > |Yvar1 | Total | %row..........................| > | | Op1 | %row..........................| > | | Op2 | %row..........................| > |+---------------------------------------------------+ > |Yvar2 | Op1 | %row..........................| > | | Op2 | %row...........................| > +----------------------------------------------------+ > |Yvar3 | Op1 | %row..........................| > | | Op2 | %row...........................| > | | Op3 | %row...........................| > |+---------------------------------------------------+ > > Like a pivot table! >?table ?xtabs ... and if you want all those dashes, dots, pluses and pipes cluttering up your output a la SAS, then there is: gmodels::Crosstable -- David.> thanks a lot. > > -- > Jonathan. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius, MD West Hartford, CT
Thanks David, gmodels::Crosstable partially work because can show only 1 x 1 tablen CrossTable(x,y,...) I need something how can process at less 1 variable in X an 10 in Y. Thanks for your help. -- Jonathan. [[alternative HTML version deleted]]
On Wed, Sep 8, 2010 at 6:40 PM, Jonathan Finlay <jmfinlayp at gmail.com> wrote:> hi, i'm new in R and i need some help. Please, ?do you know a function how > can process cross tables for many variables and show the result in one table > who look like this?: > > +----------------------------------------------------+ > |------------------ | ? ? ? ?X variable ? ? ? ? ? | > |----------------- | Xop1 | Xop2 | Xop3|.....| > +----------------------------------------------------+ > |Yvar1 | Total | %row..........................| > | ? ? ? ? | ?Op1 | ?%row..........................| > | ? ? ? ? | ?Op2 | ?%row..........................| > |+---------------------------------------------------+ > |Yvar2 | Op1 | ?%row..........................| > | ? ? ? ? | Op2 | ?%row...........................| > +----------------------------------------------------+ > |Yvar3 | Op1 | ?%row..........................| > | ? ? ? ? | Op2 | ?%row...........................| > | ? ? ? ? | Op3 | ?%row...........................| > |+---------------------------------------------------+ > > Like a pivot table! > > thanks a lot. >Try this: library(Hmisc) example(summary.formula) library(gmodels) example(CrossTable) library(remix) example(remix) -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
On Sep 8, 2010, at 7:32 PM, Jonathan Finlay wrote:> Thanks David, gmodels::Crosstable partially work because can show > only 1 x 1 > tablen > CrossTable(x,y,...) > I need something how can process at less 1 variable in X an 10 in Y.I hope you mean only two factors and an n x m table.> > Thanks for your help. > > > -- > Jonathan. > > [[alternative HTML version deleted]]-- David Winsemius, MD West Hartford, CT
It would help if you included a bit of sample data. See ?dput as a way of doing this. Also a good place to start is by looking at the package "reshape". Have a look at http://had.co.nz/reshape/ for some information on the package. --- On Wed, 9/8/10, Jonathan Finlay <jmfinlayp at gmail.com> wrote:> From: Jonathan Finlay <jmfinlayp at gmail.com> > Subject: [R] Newbie cross tabulation issue > To: r-help at r-project.org > Received: Wednesday, September 8, 2010, 6:40 PM > hi, i'm new in R and i need some > help. Please, ?do you know a function how > can process cross tables for many variables and show the > result in one table > who look like this?: > > +----------------------------------------------------+ > |------------------ |? ? ? ? X > variable? ? ? ? ???| > |----------------- | Xop1 | Xop2 | Xop3|.....| > +----------------------------------------------------+ > |Yvar1 | Total | %row..........................| > |? ? ? ???|? Op1 |? > %row..........................| > |? ? ? ???|? Op2 |? > %row..........................| > |+---------------------------------------------------+ > |Yvar2 | Op1 |? %row..........................| > |? ? ? ???| Op2 |? > %row...........................| > +----------------------------------------------------+ > |Yvar3 | Op1 |? %row..........................| > |? ? ? ???| Op2 |? > %row...........................| > |? ? ? ???| Op3 |? > %row...........................| > |+---------------------------------------------------+ > > Like a pivot table! > > thanks a lot. > > -- > Jonathan. > > ??? [[alternative HTML version deleted]] > > > -----Inline Attachment Follows----- > > ______________________________________________ > R-help at r-project.org > mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. >