I'm trying to create a function which selects a list of variables in a dataframe. The criterion is simple all variables between two selected ones.
My code so far:
var_bw <- function(v1, v2, data) {
data[ ,which(names(data)==v1):which(names(data)==v2)]
}
However, v1
and v2
need quotes around them. Must be straightforward...