Skip to content
Back to formatted view

Raw Message

Message-ID: <CAN6BBTSHwwBM7hKK7Bh0RHwChhdzeZ00aTbEptdKAYyL9=FPuQ@mail.gmail.com>
Date: 2015-08-16T09:01:00Z
From: Nikita Dinger
Subject: Error

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]]