A genomics researcher stores RNA-seq count data in a matrix with 20,000 genes (rows) and 48 samples (columns). She needs row-wise means efficiently. Which approach is fastest in R?
-
A
apply(mat, 1, mean)
-
B
rowMeans(mat)
-
C
sapply(1:nrow(mat), function(i) mean(mat[i,]))
-
D
for(i in 1:nrow(mat)) means[i] <- mean(mat[i,])