Q: How to pass all columns except one as argument to setkey()? I would like to pass column names to setkey() except one or two . I can easily do it like below:
setkey(df, column1, column2, column3, column6, ..., columnN, physical = TRUE)

(please note that column4 and column5 are skipped).
But it requires me to list all column names except some particular columns. I can get list of columns with colnames(df), but I am not sure how to (1) pass it to setkey() and (2) exclude some columns from that list?

A: You could try using setkeyv which can accept a character vector of column names and then use a simple indexing. 
For example, ignoring columns by position
setkeyv(df, names(df)[-(4:5)])

Or ignoring columns by vector of column names (combined with setdiff)
ignore <- c("column4", "column5")
setkeyv(df, setdiff(names(df), ignore))

