You have a number of options, including using %in% and grepl :
dat <- data.frame(a=1:2, b=2:3, c=4:5) dat abc 1 1 2 4 2 2 3 5
To get column names:
names(dat) [1] "a" "b" "c"
Use %in% to verify ownership:
"d" %in% names(dat) [1] FALSE Or use `grepl` to check for a match: grepl("d", names(dat)) [1] FALSE FALSE FALSE
Andrie Apr 23 2018-12-12T00: 00Z
source share