[R] how to best add columns to a matrix with many columns
Jeff Newmiller
jdnewmil at dcn.davis.CA.us
Sat May 4 05:20:54 CEST 2013
I am not seeing any good justification in your description for converting to matrix if you are planning to convert it back to data frame. Memory is going to be inefficiently-used if you do this.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
David Romano <dromano at stanford.edu> wrote:
>Hi everyone,
>
>I have large data frame, say df1, with 165K columns, and all but the
>first
>four columns of df1 are numeric. I transformed the numeric data and
>obtained a matrix, call it data.m, with 165K - 4 columns, and then
>tried to
>create a second data frame by replacing the numeric columns of df1 by
>data.m. I did this in two ways, and both ways instantly used up all
>the
>available memory, so I was wondering whether there was a better way to
>do
>this.
>
>Here's what I tried:
>
>df2 <- df1
>df2[ ,5:length(df1)] <- data.m
>
>and
>
>df2 <- cbind( df1[1:4], data.m)
>
>Thanks,
>David
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at 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.
More information about the R-help
mailing list