Suppose I have a matrix foo as follows:
foo
foo <- cbind(c(1,2,3), c(15,16,17)) > foo [,1] [,2] [1,] 1 15 [2,] 2 16 [3,] 3
library(plyr) alply(foo, 1)