Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9056163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:07:51+00:00 2026-06-16T14:07:51+00:00

Possible Duplicate: Merge multiple data frames in a list simultaneously example data.frames : df1

  • 0

Possible Duplicate:
Merge multiple data frames in a list simultaneously

example data.frames:

 df1 = data.frame(id=c('1','73','2','10','43'),v1=c(1,2,3,4,5)) <br>
 df2 = data.frame(id=c('7','23','57','2','62','96'),v2=c(1,2,3,4,5,6)) <br>
 df3 = data.frame(id=c('23','62'),v3=c(1,2)) <br>

Note: id is unique for each data.frame. I want the resulting matrix to look like

1      1 NA NA 
2      3  4 NA 
7      NA 1 NA 
10     4 NA NA 
23     NA 2  1 
43     5 NA NA 
57     NA 3 NA 
62     NA 5  2 
73     2 NA NA 
96     NA 6 NA

In this case, I only show 3 datasets, I actually have at least 22 of them so at the end I want a matrix of nx(22+1) where n is the number of ids for all 22 datasets.

Given 2 datasets, I need to get their ids in the first column and 2nd and 3rd columns are filled with the values, if there is no value exists, then input NA instead.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T14:07:52+00:00Added an answer on June 16, 2026 at 2:07 pm

    Put them into a list and use merge with Reduce

    Reduce(function(x, y) merge(x, y, all=TRUE), list(df1, df2, df3))
    #    id v1 v2 v3
    # 1   1  1 NA NA
    # 2  10  4 NA NA
    # 3   2  3  4 NA
    # 4  43  5 NA NA
    # 5  73  2 NA NA
    # 6  23 NA  2  1
    # 7  57 NA  3 NA
    # 8  62 NA  5  2
    # 9   7 NA  1 NA
    # 10 96 NA  6 NA
    

    You can also use this more concise version:

    Reduce(function(...) merge(..., all=TRUE), list(df1, df2, df3))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How can I merge two MySql tables? I want to merge multiple
Possible Duplicate: Merge two lists in python? How can I prepend list elements into
I would like to merge two data frames, but do not want to duplicate
Possible Duplicate: How can I convert a list<> to a multi-dimensional array? I want
Possible Duplicate: Python : how to append new elements in a list of list?
Possible Duplicate: Combine Multiple child rows into one row MYSQL I have following table,
Possible Duplicate: What is the best method to merge two PHP objects? I have
Possible Duplicate: Merge Two Video files in iPhone Application I have download 40mb video
Possible Duplicate: PHP Twitter API - How to pull in multiple users tweets? Is
Possible Duplicate: merge two files by key if exists in the first file /

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.