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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:29:15+00:00 2026-06-17T01:29:15+00:00

I have a data frame that looks like this: Chr start stop ref alt

  • 0

I have a data frame that looks like this:

Chr start   stop    ref alt Hom/het ID  
chr1    5179574 5183384 ref Del Het 719  
chr1    5179574 5184738 ref Del Het 915  
chr1    5179574 5184738 ref Del Het 951  
chr1    5336806 5358384 ref Del Het 376  
chr1    5347979 5358384 ref Del Het 228  

I would like to merge any duplicate rows, combining the last ID column so that all IDs are in one row/column, like this:

Chr start   stop    ref alt Hom/het ID  
chr1    5179574 5183384 ref Del Het 719  
chr1    5179574 5184738 ref Del Het 915, 951 
chr1    5336806 5358384 ref Del Het 376  
chr1    5347979 5358384 ref Del Het 228  

I have found examples of people removing duplicates and summing a column, but I just want to combine all IDs with duplicate regions in a list in a single column.

  • 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-17T01:29:17+00:00Added an answer on June 17, 2026 at 1:29 am

    Some call to aggregate() should do the trick.

    Here’s an option that collects the ID’s in a list object:

    (df1 <- aggregate(df[7], df[-7], unique))
    #   Chr   start    stop ref alt Hom.het       ID
    # 1 chr1 5179574 5183384 ref Del     Het      719
    # 2 chr1 5179574 5184738 ref Del     Het 915, 951
    # 3 chr1 5336806 5358384 ref Del     Het      376
    # 4 chr1 5347979 5358384 ref Del     Het      228
    

    And here’s one that collects them in a character vector:

    df2 <- aggregate(df[7], df[-7], 
                     FUN = function(X) paste(unique(X), collapse=", "))
    

    Comparing the results of the two options:

    str(df1$ID)
    # List of 4
    #  $ 0: int 719
    #  $ 3: int [1:2] 915 951
    #  $ 7: int 376
    #  $ 8: int 228
    
    str(df2$ID)
    # chr [1:4] "719" "915, 951" "376" "228"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data.frame that looks like this: > head(ff.df) .id pio caremgmt prev
I have a data.frame in R that looks like this: score rms template aln_id
I have a data frame in R that looks like this: > TimeOffset, Source,
I have a data.frame that looks like this > head(df) Memory Memory Memory Memory
I'm in a situation like this: I have a data.frame that looks like the
I have a data frame that looks like this: user1,product1,0 user1,product2,2 user1,product3,1 user1,product4,2 user2,product3,0
I have a ROC.Value data frame that looks like this: Years 1 2 3
I have a dataset that looks like this: a <- data.frame(rep(1,5),1:5,1:5) b <- data.frame(rep(2,5),1:5,1:5)
I have a data.frame that looks like this. x a 1 x b 2
I have a semi-melted data frame that looks like this: head(final_melt) Group Source variable

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.