combinations: Display Combinations of Column Values

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Generic, with method for data.frame. Display sorted unique rows.

Usage

1
2
3
4
5
6
7
8
9
 ## S3 method for class 'data.frame'
combinations(
 	x,
 	key=names(x),
 	depth=length(key),
 	detect=character(0),
 	count=FALSE,
 	...
 )

Arguments

x

object inheriting from data.frame

key

columns to show first (default sort criteria)

depth

integer up to length of key: actual sort criteria

detect

columns to preprocess: non-NA values will be replaced with options('defined') or just 'defined'

count

whether to tabulate the number of each unique row; logical, or length-one character giving a column name for tabulations (default: 'count')

...

ignored

Details

Columns identified as 'key' are moved to the front (by default, all).

Sorting cascades across the key columns, using the second column to break ties, etc. Permutations of column order help to make patterns obvious.

Sorting can be limited to a subset of key columns using 'depth'.

Unique rows are displayed; the number of each such is tabulated as 'count' if count is TRUE. Supply an alternate column name in place of TRUE, if you wish.

For column names in detect, all defined values are replaced with options('defined'), which you can manipulate ('defined' by default). Useful when one wishes to examine patterns of missingness, rather than actual value details.

For keyed objects, the detect affect can be achieved more simply by subsetting with a leading asterisk on column names. See examples.

Value

keyed data.frame

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
combinations(
	iris[,c('Species','Petal.Width','Sepal.Length')],
	detect='Sepal.Length',
	count=TRUE
)
# alternatively ...
iris <- as.keyed(iris)
combinations(
	iris[,c('Species','Petal.Width','*Sepal.Length')],
	count=TRUE
)

metrumrg documentation built on May 2, 2019, 5:55 p.m.