static: Return the static portion of an object.

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

Description

Tables can be repetitive for structural reasons. Repetition means, for instance, that a column value is not changing (i.e., is static) with respect to rows. The data.frame method for static detects which columns (maybe all) are static with respect to on; it returns a unique subset of rows for just those columns. The method for keyed returns by default the columns that are static on the key (i.e., static with respect to the key). static is conceptually related to constant, which returns a logical rather than a data subset.

It is possible also to retrieve just the dynamic part of the data set, or both. Currently, the work is done by lyse.data.frame which returns both and is called in turn by static.data.frame and dynamic.data.frame.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
	## S3 method for class 'data.frame'
static(x,on=character(0),strict=TRUE, ...)
	## S3 method for class 'keyed'
static(x,on=key(x),...)
	## S3 method for class 'data.frame'
dynamic(x,on=character(0),strict=TRUE, ...)
	## S3 method for class 'keyed'
dynamic(x,on=key(x),...)
	## S3 method for class 'data.frame'
lyse(x,on=character(0),strict=TRUE, ...)
	## S3 method for class 'keyed'
lyse(x,on=key(x),...)

Arguments

x

object of dispatch

on

character vector: column names in x

strict

boolean: if false, NA's will be imputed within levels of key using forbak

...

ignored

Details

By default, the data.frame method just returns unique rows for columns that are constant across the entire data.frame. If on names columns in x, those columns are retained, and other columns are retained only if their values are static within combinations of values in the implied key; again, unique rows are returned. By default, the keyed method makes the key explicit; it will be a non-operation if keys are defined and non-duplicated (i.e., all non-key columns are unique and therefore constant within the key, so the whole data.frame is returned). In all cases, the result is coerced with as.keyed, using on as the key (even if length zero).

Value

keyed data.frame; for lyse.data.frame, a list with elements static and dynamic.

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
test <- as.keyed(
	data.frame(
		SUBJ=c(1,1,1,1,1,2,2,2,2,2),
		TIME=c(1,2,3,4,5,1,2,3,4,5),
		MALE=c(1,1,1,1,1,0,0,0,0,0),
		WT=c(70,70,70,70,70,65,65,65,65,65)
	),
	c('SUBJ','TIME')
)
identical(test,static(test))
static(test)
static(test,on='SUBJ')

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