Sum Sorted Tabulation

Share:

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.

Author(s)

David Schruth

See Also

ledghead, table, order, sort

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'))
  
  

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.