trying to use lapply
or sapply
on a given mattrix using function rowSums.
Given mattrix;
mat <- matrix(1:9, ncol = 3, nrow = 3)
when I use lapply(mat, rowSums)
, it should calculate sum of all rows.
However its showing error
Error in FUN(X[[i]], ...) : 'x' must be an array of at least two dimensions Calls: sapply -> lapply -> FUN Execution halted
Where am I doing wrong, Please help.