I have a matrix of size 5000*5000, with 90% values as 0. Is there a ready-made solution available to calculate the mean, median for this matrix after excluding '0' ?
One crude solution is change all 0 to NA and use
median(x, na.rm=TRUE)
Another solution is to manually scan the matrix and create another vector containing values and then figure out mean, median etc.
Any other better alternative ?