I'm trying to find mean of all column values using R and I got the following output:
[1] NA NA 9.957516 77.882353 6.993464 15.803922
I dont want the NA values to be shows in the output, how do I go about it?
This is my code:
columnmean <- function(x) {
nc <- ncol(x)
means <- numeric(nc)
for(i in 1:nc) {
means[i] <- mean(x[, i])
}
means
}