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

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -