[R] Frequencies, proportions & cumulative proportions

David Scott d.scott at auckland.ac.nz
Sat Oct 17 02:41:41 CEST 2009


Muenchen, Robert A (Bob) wrote:
> Ted,
> 
> I know how to do that. It's just such a standard display in SAS, SPSS
> and Stata that I figured someone had done it and I had just overlooked
> it.
> 
> Thanks!
> Bob
> 
> 
> 
> I don't think there is a ready-made one, but it is very little
> effort to make your own:
> 
> mkMyTable <- function(X){
>   Table <- data.frame( table(X) )
>   Table$Prop <- prop.table( Table$Freq )
>   Table$CumProp <-  cumsum( Table$Prop )
>   Table
> }
> 
> myTable <- mkMyTable(Score)
> 
> Hoping this helps!
> Ted.
> 
I think CrossTable in gmodels does what Bob is after:

CrossTable(gmodels) R Documentation

Cross Tabulation with Tests for Factor Independence
Description
An implementation of a cross-tabulation function with output similar to 
S-Plus crosstabs() and SAS Proc Freq (or SPSS format) with Chi-square, 
Fisher and McNemar tests of the independence of all table factors.



David Scott

-- 
_________________________________________________________________
David Scott	Department of Statistics
		The University of Auckland, PB 92019
		Auckland 1142,    NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email:	d.scott at auckland.ac.nz,  Fax: +64 9 373 7018

Director of Consulting, Department of Statistics




More information about the R-help mailing list