replacing NA values with mean in shiny

i want to replace NA values with mean of specific column of data set. i tried following code

        for(i in 1:ncol(li3)){
            li3[[,i]), i] <- mean(li3[,i], na.rm = TRUE)

i got error saying argument of length 0.
why its shows length is 0?How can i solve this error

Usually argument of length 0 is caused by NULL in if statement.

For example,

Y = NA
Z = 1

if( X = 1 
# since is logical(0), which have length 0.
# this will cause "argument of length 0" error 

if( Y = 1 
# work fine

if( Z = 1 
# work fine.

I think li3 contains NULL. I don't know what me2 function does, but you should check that first.


This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.