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

c++ - What's the differece between of link to a dynamic file and as a input object? -

javascript - Feed FileReader from server side files -

Android Unit Testing / Mockito: android.location.Location not mocked -