r - Error (invalid length argument) while calling a function -


i writing function check mean of numeric columns in data frame. below code have written.

means_func <- function(x) {     nc <- ncol(sapply(x,is.numeric))    #selecting numeric columns     means <- numeric(nc)                #assigning result     (i in nc)     {     means[i] <- mean(x[i])     }     means } means_func(airquality)   #calling function 

but when call function, error error in numeric(nc) : invalid 'length' argument


Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -