[R] Error

Nikita Dinger dingernikita at gmail.com
Sun Aug 16 11:01:00 CEST 2015


Dear Sir,

I am getting this error

Error in rep(xi, length.out = nvar) :
  attempt to replicate an object of type 'closure'

I have read through the websites but cant really comprehend what this means?
Need your help.

This is my code

complete <- function(directory, idvec = 1:332) {
        df <- data.frame(id = integer(), nobs = integer())
    for (id in idvec) {
        filename <- paste(directory, "/",
                          sprintf("%03d", as.integer(id)),
                          ".csv", sep = "")
filename <- list.files()
        data <- rbind(data, read.csv(filename[id]))
}
str(data)
for (id in idvec)
        {nd <- data.frame(id = id,
                         nobs = nrow(na.omit(data)))
        df <- rbind(df, nd)
    }
    return(df)

}

	[[alternative HTML version deleted]]



More information about the R-help mailing list