On 02/07/2014, 10:33 PM, Barry Lambert wrote: > I am a new convert to R (from SAS). I am a research scientist and most of > my > use of SAS was in data analysis. Recently, I have been wanting to use R to > create a simple, reliable way to summarize a dataset of student demographics > for a university. > The spreadsheet has a row for every student registered at the university for > each term since fall 2010 with the following information about each student > in columns: > Columns are the following: Term, College, Program, Campus, Gender, > Ethnicity, Age. > > I have created summary tables in Excel using if/then type formulas to select > data and count the number of female students in program A at location 3, > etc. > > I have written some R code to create some figures that generally meet my > needs. > I would like to find a way to have R populate some tables with this type of > information. > > An example of my excel sheets are attached. >
The "tables" package has formulas that are like PROC TABULATE formulas (except better :-). Your samples would be something like tabular( term ~ campus * college ) tabular( college * program ~ campus * term ) The second one will need some extra work to remove all the empty cells (e.g. College 1 Program 3 will show up, even though it doesn't really exist). See the vignette for a couple of approaches to handling this. The package is mainly aimed at LaTeX output, but it can produce HTML, or just put the numbers in a CSV file for pasting into some spreadsheet for manual formatting. Duncan ______________________________________________ R-help@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.