Learn R Programming

funModeling (version 1.6.6)

filter_vars: Filtering variables by string name

Description

Based on the variables name present in 'str_input', it returns the original data frame (keep=T), or it deletes all except the desired ones.

Usage

filter_vars(data, str_input, keep = TRUE)

Arguments

data

data frame

str_input

string vector containing variables to delete or to keep

keep

boolean indicating if the variables names in 'str_input' must be kept or

Value

Filtered data frame

Examples

Run this code
# NOT RUN {
# Selecting variables
my_data_1=filter_vars(mtcars, str_input=c('mpg', 'cyl'))
colnames(my_data_1)

# Deleting all except desired variables
my_data_2=filter_vars(mtcars, str_input=c('mpg', 'cyl', 'qsec', 'vs'), keep=FALSE)
colnames(my_data_2)
# }

Run the code above in your browser using DataLab