[R] Merge or combine data frames with missing columns

Rowe, Brian Lee Yung (Portfolio Analytics) B_Rowe at ml.com
Mon Dec 29 18:12:37 CET 2008


Mark,

I think ?rbind should work for you.

Regards,
Brian

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Mark Heckmann
Sent: Monday, December 29, 2008 9:18 AM
To: r-help at r-project.org
Subject: [R] Merge or combine data frames with missing columns



Hi R-experts,

suppose I have a list with containing data frame elements:

[[1]]
(Intercept)          y1          y2          y3          y4 
 -6.64              0.761      0.383      0.775      0.163
 
[[2]]
(Intercept)          y2          y3          
-3.858             0.854      0.834     

Now I want to put them into ONE dataframe like this:
               (Intercept)           y1          y2         y3           y4 
   1           -6.64              0.761      0.383      0.775      0.163
   2         -3.858                  NA       0.854      0.834        NA

The problem I encounter is that not always all possible columns (Intercept,  y1,  y2, y3,  y4) exist or at least have NA entries .

I cannot figure out how (e.g. with merge)...

TIA, Mark


-- 
Mark Heckmann (Dipl. Wirt.-Ing.)
phone +49 (0) 421/1614618

Sensationsangebot verlängert: GMX FreeDSL - Telefonanschluss + DSL 
für nur 16,37 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K1308T4569a

______________________________________________
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.

--------------------------------------------------------------------------
This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing.
--------------------------------------------------------------------------



More information about the R-help mailing list