Learn R Programming

ribiosUtils (version 1.5-6)

subsetByColumnName: Subset a data.frame by column name, allowing differences in cases

Description

The function calls assertColumnName internally to match the column names.

Usage

subsetByColumnName(data.frame, reqCols, ignore.case = FALSE)

Arguments

data.frame

A data.frame object

reqCols

required columns

ignore.case

logical, whether the case is considered

Value

If all required column names are present, the data.frame object will be subset to include only these columns and the result data.frame is returned. Otherwise an error message is printed.

Examples

Run this code
# NOT RUN {
myTestDf <- data.frame(HBV=1:3, VFB=0:2, BVB=4:6, FCB=2:4)
myFavTeams <- c("HBV", "BVB")
subsetByColumnName(myTestDf, myFavTeams)
myFavTeamsCase <- c("hbv", "bVb")
subsetByColumnName(myTestDf, myFavTeamsCase, ignore.case=TRUE)

# }

Run the code above in your browser using DataLab