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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:20:38+00:00 2026-05-25T13:20:38+00:00

I am searching several large files for replicate gene entries. There are several duplicates

  • 0

I am searching several large files for replicate gene entries. There are several duplicates and at least one triplcate entry in my list of genes. I just want to be able to find out what lines are reps’!?!

I get the error:

Error in if (genes[i, 1] == genes[j, 1] && i != j) { : 
missing value where TRUE/FALSE needed

I am at a roadblock.

genes <- combine[c(4)]
num_rows <- nrow(genes)
dup_combine <- vector(mode="character", length=100)
n=1
for (i in 1:num_rows) {
only_check_rows <- num_rows-1
   for (j in i+1:only_check_rows) {
      if (genes[i,1] == genes[j,1]&&i!=j) {
         dup_combine[n] <- combine[i,1]
         n=n+1
         cat("i=",i,"j=",j,"\n")
      }
   }
}
  • 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-25T13:20:38+00:00Added an answer on May 25, 2026 at 1:20 pm

    It looks like you are searching for duplicates in a single vector (genes). There are several ways to do this. Here’s some example data:

    dat <- c(1,2,3,2,4,4,6,NA,8,NA,13)
    

    table will count the number of occurences of each unique value in dat. Note I use exclude = NULL to force it to count NA values as well:

    table(dat, exclude = NULL)
    

    As mentioned in a comment, duplicated also applies. This function returns a boolean vector indicating specifically which entries are duplicates of previous entries. fromLast = TRUE tells it to look from back to front, rather than from front to back.

    duplicated(dat)
    duplicated(dat, fromLast = TRUE)
    

    You can combine these two directions to get all the duplicated elements:

    subset(dat, duplicated(dat) | duplicated(dat, fromLast = TRUE))
    

    If you are working with data frames, rather than single vectors, duplicated is probably the way to go.

    Edit

    Here’s a short worked example using a sample data frame:

    dat <- data.frame(x = c(1,2,3,4,4,5,6,5,9),
            y = c(2,3,1,2,2,6,2,6,10))
    > dat
      x  y
    1 1  2
    2 2  3
    3 3  1
    4 4  2
    5 4  2
    6 5  6
    7 6  2
    8 5  6
    9 9 10
    
    #Boolean vector of duplicated rows
    duplicated(dat)
    [1] FALSE FALSE FALSE FALSE  TRUE FALSE FALSE  TRUE FALSE
    
    #Indices of duplicated rows   
    which(duplicated(dat))
    [1] 5 8
    
    #Look in both directions to get all dups (indices)
    which(duplicated(dat) | duplicated(dat,fromLast = TRUE))
    [1] 4 5 6 8
    
    #The actual rows
    subset(dat,duplicated(dat) | duplicated(dat, fromLast = TRUE))
      x y
    4 4 2
    5 4 2
    6 5 6
    8 5 6
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am searching for a way to add several files into one file, much
After searching stackoverflow.com I found several questions asking how to remove duplicates, but none
I have several large Javascript files that I need to document/digg into. Unfortunately I
I have some large files (from several gigabytes to hundreds of gigabytes) that I'm
I've seen binary trees and binary searching mentioned in several books I've read lately,
Many hex editors, such as Hex Workshop, can even read large-sized files while keeping
I know there are already several similar questions here, but I need some recommendations
After spending several hours today searching and seeing several people having the same issue,
I have some large files (hundreds of MB) that I need to search for
I have some large pcap (packet capture) files collected with tcpdump. I would like

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.