Last data update: 2014.03.03

R: Select several rows and columns from a data object
selR Documentation

Select several rows and columns from a data object

Description

This function acts similarly as the [] operator, i.e. selects rows and columns of a data object.

Usage

sel(x, ...)
## S3 method for class 'farules'
sel(x, 
                      i=rep(TRUE,
                      nrow(x)), 
                      ...)
## S3 method for class 'fsets'
sel(x,
                    i=rep(TRUE, nrow(x)),
                    j=rep(TRUE, ncol(x)),
                    ...)

Arguments

x

Original data: originally an instance of class fsets or farules.

i

The specification of rows to be selected. It can be a vector of integer indices which have to be selected, or vector of negative integers specifying which rows to discard, or vector of logical values etc. See [ for details.

j

The specification of columns to be selected (only applicable for instances of fsets). It can be a vector of integer indices which have to be selected, or vector of negative integers specifying which columns to discard, or vector of logical values etc. See [ for details.

...

Other parameters to some methods.

Details

Originally, it is an S3 method defined for fsets and farules classes.

For instances of the fsets class, sel behaves similarly as the [] operator except that it also takes care of the vars and specs attributes. Therefore, if you want to select some rows or columns from the fsets object and obtain again a valid fsets object, use sel. If you want only a matrix or vector of membership degrees in the fsets object without any other attributes, use the [] operator.

For instances of the farules class, sel returns a valid farules object with a subset of rules specified with the i argument. Also the matrix of statistics is handled appropriately.

Value

A subset of data (originally fsets or farules) of the same type as original data, with attributes and additional meta data handled correctly.

Author(s)

Michal Burda

See Also

fsets, fcut, lcut, cbind.fsets, farules, searchrules

Examples

    x <- 0:100
    d <- fcut(x, 
              breaks=c(0, 25, 50, 75, 100),
              type='triangle')

    # select only first two columns
    res <- sel(d, , 1:2)
    print(res)

    # select only the 3rd row
    res <- sel(d, 3)
    print(res)

Results