I would like to make the following faster:

        df <- NULL
        for(i in 1:length(s))
        {
                df <- rbind(df, cbind(names(s[i]), time(s[[i]]$series), 
as.vector(s[[i]]$series), s[[i]]$category))
        }
        names(df) <- c("name", "time", "value", "category")
        return(df)

The s object is a list of lists. It is constructed like:

s[["object"]] <- list(. . . . . .)

where "object" would be the name associated with this list s[[i]]$series 
is a 'ts' object and s[[i]]$category is a name.

Constructing this list is reasonably fast but to do some more processing 
on the data it would be easier if it were converted to a data frame. 
Right now the above code is unacceptably slow at converting this list of 
lists to a data frame. Any suggestions on how to optimize this are 
welcome.

Thank you.

Kevin

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