Issue with NA values in R

前端 未结 3 857
时光取名叫无心
时光取名叫无心 2021-01-22 07:44

I feel this should be something easy, I have looked x the internet, but I keep getting error messages. I have done plenty of analytics in the past but am new to R and programmin

3条回答
  •  遥遥无期
    2021-01-22 08:01

    You should be using that parameter in the mean function call:

    columnmean <-function(y){
      nc <- ncol(y)
      means <- numeric(nc)
      for(i in 1:nc) {
        means[i] <- mean(y[,i], na.rm = TRUE)
      }
        means 
    }
    

    columnmean is a custom function and does not have that parameter.

提交回复
热议问题