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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:15:33+00:00 2026-05-31T19:15:33+00:00

I have many data.frames, for example: df1 = data.frame(names=c(‘a’,’b’,’c’,’c’,’d’),data1=c(1,2,3,4,5)) df2 = data.frame(names=c(‘a’,’e’,’e’,’c’,’c’,’d’),data2=c(1,2,3,4,5,6)) df3 =

  • 0

I have many data.frames, for example:

df1 = data.frame(names=c('a','b','c','c','d'),data1=c(1,2,3,4,5))
df2 = data.frame(names=c('a','e','e','c','c','d'),data2=c(1,2,3,4,5,6))
df3 = data.frame(names=c('c','e'),data3=c(1,2))

and I need to merge these data.frames, without delete the name duplicates

> result
  names data1 data2 data3
1  'a'    1    1      NA
2  'b'    2    NA     NA
3  'c'    3    4      1
4  'c'    4    5      NA
5  'd'    5    6      NA
6  'e'    NA   2      2       
7  'e'    NA   3      NA

I cant find function like merge with option to handle with name duplicates. Thank you for your help.
To define my problem. The data comes from biological experiment where one sample have a different number of replicates. I need to merge all experiment, and I need to produce this table. I can’t generate unique identifier for replicates.

  • 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-05-31T19:15:34+00:00Added an answer on May 31, 2026 at 7:15 pm

    First define a function, run.seq, which provides sequence numbers for duplicates since it appears from the output that what is desired is that the ith duplicate of each name in each component of the merge be associated. Then create a list of the data frames and add a run.seq column to each component. Finally use Reduce to merge them all.

    run.seq <- function(x) as.numeric(ave(paste(x), x, FUN = seq_along))
    
    L <- list(df1, df2, df3)
    L2 <- lapply(L, function(x) cbind(x, run.seq = run.seq(x$names)))
    
    out <- Reduce(function(...) merge(..., all = TRUE), L2)[-2]
    

    The last line gives:

    > out
      names data1 data2 data3
    1     a     1     1    NA
    2     b     2    NA    NA
    3     c     3     4     1
    4     c     4     5    NA
    5     d     5     6    NA
    6     e    NA     2     2
    7     e    NA     3    NA
    

    EDIT: Revised run.seq so that input need not be sorted.

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

Sidebar

Related Questions

I have two data frames, Data1 and Data2, that I want to merge based
Suppose that you have a data frame with many rows and many columns. The
For example, I have a data frame with data across categories and subcategories and
I have very wide data frame and would like to create many short data
I have many forms that use AJAX (w/ jQuery) for validation and data submission.
I have a star schema type data base, with fact tables that have many
Many applications have grids that display data from a database table one page at
I have a to-many relationship in my data model, and I'd like to get
I have a table with many rows of data, and I want to show
We have a large number of data in many categories with many properties, e.g.

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.