Q:

In R: how to specify non-adjacent columns in function parameters

variable <- some.function(some.datafile, data.col=4:6)

How would I designate columns 4 and 6, but not 5?
I have tried c(4,6) and 4,6.   

A:

It should work with c(4, 6) and [] subsetting. For instance, this works for me:
someFunction <- function(x, n) {
  y <- x[n]
  y
}

test <- data.frame(x = rnorm(10),
                   y = rnorm(10),
                   z = rnorm(10))
someFunction(test, 1)
someFunction(test, 1:3)
someFunction(test, c(1, 3))

