R/dfmat.R
subsetByColumnName.Rd
The function calls assertColumnName
internally to match the
column names.
subsetByColumnName(data.frame, reqCols, ignore.case = FALSE)
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.
myTestDf <- data.frame(HBV=1:3, VFB=0:2, BVB=4:6, FCB=2:4)
myFavTeams <- c("HBV", "BVB")
subsetByColumnName(myTestDf, myFavTeams)
#> HBV BVB
#> 1 1 4
#> 2 2 5
#> 3 3 6
myFavTeamsCase <- c("hbv", "bVb")
subsetByColumnName(myTestDf, myFavTeamsCase, ignore.case=TRUE)
#> hbv bVb
#> 1 1 4
#> 2 2 5
#> 3 3 6