Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replicate "Custom Tables" comparison in R

Tags:

r

spss

I use SPSS everyday but have really been trying to learn R. The major thing that is holding me back is my need to easily generate tables, banners, and cross-tabs for the market research that I do. I love the Custom Tables option in SPSS and am looking for advice on how to replicate it with R.

I believe R has a ton of advantages over SPSS, one of which is the ability to integrate with LaTeX for reproducible reports. SPSS is great for quick exploration (point and click), but leaves alot to be desired when taking the results and packaging it to an acceptable deliverable for clients, etc. That said, R is so powerful, I feel like I could do everything I need in it if I could only do my banners/crosstabs the way I need them.

In short, what are my options to generate report-worthy tables similar to what I have below? I am copying the SPSS syntax command and the output for reference.

CTABLES 
  /VLABELS VARIABLES=age educ paeduc maeduc speduc prestg80 happy 
    DISPLAY=DEFAULT 
  /TABLE age [MEAN F40.3, VALIDN COMMA40.0] + educ [MEAN F40.3, VALIDN COMMA40.0] + paeduc [MEAN F40.3, VALIDN COMMA40.0] + maeduc [MEAN F40.3, VALIDN COMMA40.0] + speduc [MEAN F40.3, VALIDN COMMA40.0] + prestg80 [MEAN F40.3, VALIDN COMMA40.0] BY happy 
  /SLABELS POSITION=ROW 
  /CATEGORIES VARIABLES=happy ORDER=A KEY=VALUE EMPTY=INCLUDE TOTAL=YES POSITION=AFTER MISSING=EXCLUDE 
  /SIGTEST TYPE=CHISQUARE ALPHA=0.05 INCLUDEMRSETS=YES CATEGORIES=ALLVISIBLE 
  /COMPARETEST TYPE=MEAN ALPHA=0.05 ADJUST=BONFERRONI ORIGIN=COLUMN INCLUDEMRSETS=YES CATEGORIES=ALLVISIBLE MEANSVARIANCE=ALLCATS MERGE=NO 
  /COMPARETEST TYPE=PROP ALPHA=0.05 ADJUST=BONFERRONI ORIGIN=COLUMN INCLUDEMRSETS=YES CATEGORIES=ALLVISIBLE MERGE=NO.

I attached a picture of what the output looks like. I am particuarly interested in the ability to have multiple variables in the rows/columns and like the flexibility to nest them if I need to. In the image, I have a few continuous variables cut by a categorical variable in the column with the summary statistics placed in the rows. As an aside, I also really like the feature of quick column mean comparisons -- but figure in can quickly access them in R for conditional crosstab generation.

like image 448
Btibert3 Avatar asked Jul 29 '10 14:07

Btibert3


1 Answers

Try to explore a "tabular" function from the "tables" package. I think it might be helpful.

like image 72
Václav Cepelak Avatar answered Sep 27 '22 19:09

Václav Cepelak