x <- matrix( rnorm(1000 * 2000), ncol = 2000 )
system.time( rowMins(x) )
system.time( apply(x, 1, min) )
s1 = rowMins(x)
s2 = apply(x, 1, min)
system.time( rowMaxs(x) )
system.time( apply(x, 1, max) )
s1 = rowMaxs(x)
s2 = apply(x, 1, max)
Run the code above in your browser using DataLab