X = matrix(runif(10),ncol=2);
rowSums(X) == apply(X,1,sum)
apply(X,1,sum) == Apply.function(sum,X)
X = matrix(runif(10),ncol=1)
rowSums(X) == apply(X,1,sum)
apply(X,1,sum) == Apply.function(sum,X)
X = matrix(runif(10),ncol=2)
f = function(X) X[1]/X[2]
apply(X,1,f) == Apply.function(f,X)
Run the code above in your browser using DataLab