selectSubsets {DASplusR}R Documentation

DASData - subsets

Description

The function 'selectSubsets()' adds an attribute to a data object of class 'DASData'. The attribute is named 'selectedSubsets' and stores a vector with character-elements each specifying a subset name.

Usage

selectSubsets(dat,subs)

Arguments

dat a data object of class 'DASData', which will be enriched ba an attribute 'selectedSubsets'.
subs a vector of integers, specifying the subsets to be selected by the number in the list of 'subsets', or a vector of subset names. Specifying subs=c(0,...) causes to delete the whole attribute named 'selectedSubsets' and resets the attributes to NA, where it does not matter what follows 0.

In any case the index information will be stored as vector of character elements naming subsets.

Details

The function adds an attribute with name 'selectedSubsets' to the DataSet 'dat'. By that for certain functions dataset 'dat' is represented by these subsets.

The names of subsets can be accessed via 'attributes(attributes(dat)$subsets)$names' if someone wants to see what the names of the subsets so far are.

Value

The function returns TRUE or FALSE regarding the success of the workflow. The new object is copied to the working environment and is visible there.

Note

There are no missing values allowed.

Author(s)

Stefan Schnabl, stefan.schnabl@gmail.com

See Also

'removeSubsets', 'makeSubsets', 'makeDASData', 'attributes', 'attr'

Examples

# example data object of class data.frame
x = 1:5
dat = data.frame(cbind(x1=x,x2=x,x3=x,x4=x),row.names=c("y1","y2","y3","y4","y5"))
attach(dat)
makeSubset(dat,"sub1","x1<4")
makeSubset(dat,"sub2",1:3)
makeSubset(dat,"sub3",c(T,F,T,F,T))
makeSubset(dat,"sub4",c(0,1,1,0,0))
makeSubset(dat,"sub5",c("y2","y3"))
makeSubset(dat,"sub6",c(1,3,5))

# access subset names
attributes(attributes(dat)$subsets)$name

# select subsets by integer
selectSubsets(dat,c(1,3,5))

# select subsets by name
selectSubsets(dat,c("sub1","sub3","sub5"))

# remove the whole attribute
selectSubsets(dat,0)

[Package DASplusR version 0.0-1 Index]