tags:

views:

59

answers:

4

Hi everyone,

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.

http://yfrog.com/msvp3dj

A: 

See xtable package for some table exporting to LaTeX and HTML. There may be other packages, though. This looks promising as well. Have you heard of Sweave?

Roman Luštrik
I have - I figure once I figure out a way to create summary tables/banners/cross tabs the way I need them, it will be easy to automate my reports using Sweave. That said, the first hurdle is creating the tables.......
Btibert3
+1  A: 

This is something that is not currently easy in R. You are likely to have to string together multiple functions from multiple packages to get output like this.

hadley
Thanks Hadley. I am getting that impression, which is a huge bummer. That said, your packages are fantastic!
Btibert3
A: 

I just downloaded the package psych, and it is pretty good at producing tables for summary statistics broken down by variables. it doesn't format as nice as say stata. I think you can output it into a text file and then format it the way you want.

Alison
+1  A: 

There were several presentations on this topic at useR 2010, so you may see more packages out soon that attempt to address this.

Elaine