Learn R Programming

fifer (version 1.1)

make.null: Drop or keep variables in a dataset

Description

Given a set of variable names (or integers), remove (or keep) these columns from a dataset

Usage

make.null(..., data, keep = FALSE)

Arguments

...
objects (either vectors of strings, vectors of numbers, or both)
data
the dataset you're trying to eliminate (or keep) variables from
keep
should the variables be kept (keep=T) or dropped (keep=F)?

Value

a dataset, containing the variables of interest only

See Also

subset. get.cols, r

Examples

Run this code
data = data.frame(matrix(rnorm(100), ncol=5))
names(data) = LETTERS[1:5]

#### extract only the classification
data(iris)
new.data = make.null(c("Sepal.Length"), 
       r("Sepal.Width", "Petal.Width", names(iris)), data=iris)

#### extract all but the classification
new.data2 = make.null(c("Sepal.Length"), 
   r("Sepal.Width", "Petal.Width", names(iris)), data=iris, keep=TRUE)

Run the code above in your browser using DataLab