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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:40:26+00:00 2026-05-26T07:40:26+00:00

I have a large data frame that Im working with, the first few lines

  • 0

I have a large data frame that Im working with, the first few lines are as follows:

      Assay   Genotype   Sample    Result
1     001        G         1         0
2     001        A         2         1
3     001        G         3         0 
4     001        NA        1         NA
5     002        T         1         0
6     002        G         2         1
7     002        T         2         0 
8     002        T         4         0
9     003        NA        1         NA

In total I’ll be working with 2000 samples and 168 Assays for each sample.

Id like to extract the lines where I have multiple entries with both the same Assay and Sample. I want the resulting data to be in a data frame containing all of the duplicate entries, sorted such that the duplicates are next to each other. From the example above the result would look like this:

      Assay   Genotype   Sample    Result
1     001        G         1         0
4     001        NA        1         NA
6     002        G         2         1
7     002        T         2         0 
  • 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-26T07:40:27+00:00Added an answer on May 26, 2026 at 7:40 am

    Demo data for easy loading:

    df <- structure(list(Assay = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L), Genotype = structure(c(2L, 1L, 2L, NA, 3L, 2L, 3L, 3L, NA), .Label = c("A", "G", "T"), class = "factor"), Sample = c(1L, 2L, 3L, 1L, 1L, 2L, 2L, 4L, 1L), Result = c(0L, 1L, 0L, NA, 0L, 1L, 0L, 0L, NA)), .Names = c("Assay", "Genotype", "Sample", "Result"), class = "data.frame", row.names = c("1", "2", "3", "4", "5", "6", "7", "8", "9"))
    

    You could easily get the dupicated Assay/Sample pairs with duplicated:

    vars <- c('Assay', 'Sample')
    dup <- df[duplicated(x[, vars]), vars]
    

    Resulting in:

    > dup
      Assay Sample
    4     1      1
    7     2      2
    

    Which needs a simple merge for required result:

    > merge(dup, df)
      Assay Sample Genotype Result
    1     1      1     <NA>     NA
    2     1      1        G      0
    3     2      2        G      1
    4     2      2        T      0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large data frame that Im working with, the first few lines
I'm working with a large data frame, and have run up against RAM limits.
I have a large data.frame that was generated by a process outside my control,
I have a large data frame (named z ) that looks like this: RPos
I have a large data.frame displaying some weird properties when plotted. I'd like to
I have a very large possible data set that I am trying to visualize
I have a large data.frame, and I'd like to be able to reduce it
I have a data.frame that looks like this > head(df) Memory Memory Memory Memory
I have a data frame of integers that is a subset of all of
I have a large data frame with the following fields (example data). #dput(data) gives...

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.