# NOT RUN {
##
## 1. return index
##
dd <- data.frame(a = gl(3,4), b = gl(4,1,12)) # balanced 2-way
mm <- model.matrix(~ a + b, dd)
b. <- rgrep(names(dd), colnames(mm)[5])
# check
# }
# NOT RUN {
all.equal(b., 2)
# }
# NOT RUN {
##
## 2. return value
##
bv <- rgrep(names(dd), colnames(mm)[5], value=TRUE)
# check
# }
# NOT RUN {
all.equal(bv, 'b')
# }
Run the code above in your browser using DataLab