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 9256433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:56:25+00:00 2026-06-18T11:56:25+00:00

I would like to merge multiple data.frame in R using row.names , doing a

  • 0

I would like to merge multiple data.frame in R using row.names, doing a full outer join. For this I was hoping to do the following:

x = as.data.frame(t(data.frame(a=10, b=13, c=14)))
y = as.data.frame(t(data.frame(a=1, b=2)))
z = as.data.frame(t(data.frame(a=3, b=4, c=3, d=11)))
res = Reduce(function(a,b) merge(a,b,by="row.names",all=T), list(x,y,z))

Warning message:
In merge.data.frame(a, b, by = "row.names", all = T) :
  column name ‘Row.names’ is duplicated in the result
> res
  Row.names Row.names V1.x V1.y V1
    1         1         a   10    1 NA
    2         2         b   13    2 NA
    3         3         c   14   NA NA
    4         a      <NA>   NA   NA  3
    5         b      <NA>   NA   NA  4
    6         c      <NA>   NA   NA  3
    7         d      <NA>   NA   NA 11

What I was hoping to get would be:

    V1 V2 V3
  a 10 1  3
  b 13 2  4
  c 14 NA 3
  d NA NA 11
  • 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-18T11:56:26+00:00Added an answer on June 18, 2026 at 11:56 am

    The following works (up to some final column renaming):

    res <- Reduce(function(a,b){
            ans <- merge(a,b,by="row.names",all=T)
            row.names(ans) <- ans[,"Row.names"]
            ans[,!names(ans) %in% "Row.names"]
            }, list(x,y,z))
    

    Indeed:

    > res
      V1.x V1.y V1
    a   10    1  3
    b   13    2  4
    c   14   NA  3
    d   NA   NA 11
    

    What happens with a row join is that a column with the original rownames is added in the answer, which in turn does not contain row names:

    > merge(x,y,by="row.names",all=T)
      Row.names V1.x V1.y
    1         a   10    1
    2         b   13    2
    3         c   14   NA
    

    This behavior is documented in ?merge (under Value)

    If the matching involved row names, an extra character column called
    Row.names is added at the left, and in all cases the result has
    ‘automatic’ row names.

    When Reduce tries to merge again, it doesn’t find any match unless the names are cleaned up manually.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple (more than 2) dataframes I would like to merge. They all
I would like to add a column to a data frame with the count
I would like to make a series of plots using ggplot from multiple different
I am using VS2005 C# and SQL2005. I would like to retrieve data from
I have multiple JSON files that I would like to parse, edit, and merge
I have two classes that I would like to merge into a composite. These
That one is a tricky one I believe. I would like to merge two
I would like to be able to merge two files into one during configure
I would like to know how difficult it would be to merge the well-designed
Seems like it would be better if you did commit followed by merge. I'm

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.