Learn R Programming

sr (version 0.1.0)

select_by_mask: Select by Mask

Description

Select columns from a matrix using an integer bitmap

Usage

select_by_mask(data, intMask)

Value

A matrix containing the columns of data for which intMask is 1

Arguments

data

A numeric matrix in tidy form

intMask

An Integer vector whose length equals number of columns in data

Details

Selects columns from a matrix. A column is included in the output when the corresponding mask value is 1.

Examples

Run this code
e12 <- embed(mgls, 13)
tn <- e12[ , 1]
pn <- e12[ ,2:13]
msk <- integer(12)
msk[c(1,2,3,4,6,7,9)] <- 1  # select these columns
p <- select_by_mask(pn, msk)
gamma_test(predictors = p, target = tn)

msk <- int_to_intMask(15, 12)     # pick out the first four columns
p <- select_by_mask(pn, msk)
gamma_test(predictors = p, target = tn)

Run the code above in your browser using DataLab