Take iris from R Base from example:
library(datasets) data(iris)?iris The following four command will generate the same results: the means of the first four columns in the document. colMeans(iris[1:4]) colMeans(iris[,1:4]) apply(iris[1:4], 2, mean) apply(iris[, 1:4], 2, mean) Not sure why R knows that 1:4 refers to the columns, but not the rows. Perhaps it is because it corresponds to the "2" in the command.