# sstable: Sum Sorted Tabulation In caroline: A Collection of Database, Data Structure, Visualization, and Utility Functions for R

## Description

A wrapper for the "table()" function that also calculates the row-wise sum and sorts by the new column.

## Usage

 `1` ```sstable(x, idx.clmns, ct.clmns = NULL, na.label = "NA") ```

## Arguments

 `x` list of vectors or a dataframe `idx.clmns` index columns `ct.clmns` count columns `na.label` row label used for na columns

## Value

A dataframe sorted by the count columns.

David Schruth

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14``` ``` e <- data.frame(a=runif(12),b=runif(12), z=rep(letters[13:18],2),w=rep(letters[20:23],3)) e <- data.frame(a=runif(10),b=runif(10), z=rep(letters[12:16],2),w=rep(letters[20:24],2)) sstable(e, idx.clmns=c('z','w'), ct.clmns='a') sstable(e, idx.clmns=c('z'), ct.clmns=c('a','b')) sstable(e, idx.clmns=c('z','w')) e <- data.frame(a=10,b=0, z=as.factor(NA)) sstable(e, 'z', c('a','b')) e <- data.frame(a=10,b=0, z=NA, w=NA) sstable(e, 'z', c('a','b')) e <- data.frame(a=runif(10),b=runif(10),m=rep(c('one','two'),5), z=factor(rep('z',10), levels=c('z','x'))) sstable(e, idx.clmns=c('m','z')) ```

caroline documentation built on May 29, 2017, 12:09 p.m.