Passing expression through functions
问题 I'm using data.table package and trying to write a function (shown below): require(data.table) # Function definition f = function(path, key) { table = data.table(read.delim(path, header=TRUE)) e = substitute(key) setkey(table, e) # <- Error in setkeyv(x, cols, verbose = verbose) : some columns are not in the data.table: e return(table) } # Usage f("table.csv", ID) Here I try to pass an expression to the function. Why this code doesn't work? I've already tried different combinations of