Learn R Programming

fifer (version 1.1)

drop.columns: Drop (or keep) all columns containing a vector of strings

Description

Drop (or keep) all columns containing a vector of strings

Usage

drop.columns(string, data, drop = TRUE)

Arguments

string
The string (or vector of strings) to be kept or omitted.
data
The dataset
drop
Logical. Should the columns containing string be dropped?

Value

a dataset with the column(s) dropped or kepts

References

http://stackoverflow.com/questions/7597559/grep-in-r-with-a-list-of-patterns

See Also

make.null

Examples

Run this code
### drop all columns with the words "Length"
data(iris)
iris.dropped = drop.columns("Length", data=iris, drop=TRUE)

### keep only those columns with HemoLeptin in the string
data(fakeMedicalData)
medical = drop.columns("HemoLeptin", data=fakeMedicalData, drop=FALSE)
head(medical)

Run the code above in your browser using DataLab