subset.connectedness {connectedness}R Documentation

Subset data by disconnected subsets

Description

subset.connectedness helps you to subset data based on disconnected subsets.

Usage

subset.connectedness(x, data, ..., subset=NULL, dropNA=NULL)

Arguments

x connectedness, output from connectedness
data data.frame, data
... arguments passed to subset.data.frame
subset integer, subset number(s), see details
dropNA logical, drop subsets with missing levels, see details

Details

subset defines which subsets of records will stay in output of this function. This value is used to compute value for subset argument for default subset method for a data.frame. If subset=NULL "all" records will be returned.

FIXME

If there are any NA's in the data, a call of connectedness, not exactly all records will be returned here because connectedness excludes records with NA's (subject to change/improve in future).

If subset slot in x is NULL, the following error is issued "subset slot is empty". This is due to the use of argument subset=FALSE in connectedness to get lean output in case of big datasets. You will have to rerun connectedness with subset=TRUE to overcome this issue.

Argument dropNA can be used to remove data.frame rows that have unused levels for either factor that was used in connectedness. By default value is taken from object x.

Value

Data.frame with records that correspond to defined subsets in subset.

Author(s)

Gregor Gorjanc

See Also

connectedness, levelsBySubset, plot.connectedness and subset

Examples


data(connect)
table(connect$group, connect$season)
tmp <- connectedness(x=connect$group, y=connect$season)
tmpD <- connectedness(x=connect$group, y=connect$season, drop=TRUE)

## Subset method
subset(x=tmp, data=connect)
subset(x=tmpD, data=connect)
subset(x=tmp, data=connect, dropNA=TRUE)
subset(x=tmp, data=connect, subset=1)
subset(x=tmp, data=connect, subset=2)
subset(x=tmp, data=connect, subset=c(1, 2))

[Package connectedness version 0.2.2 Index]