On Tue, Feb 14, 2012 at 2:31 PM, William Dunlap <wdun...@tibco.com> wrote:

> If you must repeatedly append rows to a data.frame,
> try making the dataset you are filling in a bunch
> of independent vectors, perhaps in a new environment
> to keep things organized.


One complication is I don't know the names of the columns I'm assigning to
before I read them off the file. And crazily, if I change this:
       data$x[i] <- i + 0.1

where data is an environment and x a primitive vector, to use a computed
name instead:

 data[[colname]][i] <- i + 0.1

Then I get back to way-superlinear performance. Eventually I found I could
work around it like:

eval(substitute(var[ix] <- data,
                          list(var=as.name(colname), ix=i, data = i+0.1)),
               envir = data)

but... as workarounds go that seems to be on the crazy nuts end of the
scale. Why does [[]] impose a performance penalty?

Peter

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to