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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:45:34+00:00 2026-06-11T08:45:34+00:00

I have a data set I would like to remove the rows of data

  • 0

I have a data set I would like to remove the rows of data that have duplicate information in 4 different columns.

foo<- data.frame(g1 = c("1","0","0","1","1"), v1 = c("7","5","4","4","3"), v2 = c("a","b","x","x","e"), y1 = c("y","c","f","f","w"), y2= c("y","y","y","f","c"), y3 = c("y","c","c","f","w"), y4= c("y","y","f","f","c"), y5=c("y","w","f","f","w"), y6=c("y","c","f","f","w"))

foo then looks like:

  g1 v1 v2 y1 y2 y3 y4 y5 y6
1  1  7  a  y  y  y  y  y  y
2  0  5  b  c  y  c  y  w  c
3  0  4  x  f  y  c  f  f  f
4  1  4  x  f  f  f  f  f  f
5  1  3  e  w  c  w  c  w  w

Now, I want to remove any row that has duplicated data based on the Y1-6columns. So, only row 4 and 1 would be removed if done properly, based on all Y variables being the exact same. Its a multiple column condition.

I believe I am close, but its just not working correctly.

I have tried: new = foo[!(duplicated(foo[,1:6]))]
thinking to use the duplicated command that it would search and only find those that matched exactly?

I thought about using a conditional statement with &, but can’t figure out how to do that either.
new = foo[foo$y1==foo$y2|foo$y3|foo$y4|foo$y5|foo$y6]

I thought about which but Im now overwhelmed and lost. I would expect foo to look like:

   g1 v1 v2 y1 y2 y3 y4 y5 y6
2  0  5  b  c  y  c  y  w  c
3  0  4  x  f  y  c  f  f  f
5  1  3  e  w  c  w  c  w  w
  • 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-11T08:45:35+00:00Added an answer on June 11, 2026 at 8:45 am
    > foo[apply(foo[ , paste("y", 1:6, sep = "")], 1,
                FUN = function(x) length(unique(x)) > 1 ), ]
      g1 v1 v2 y1 y2 y3 y4 y5 y6
    2  0  5  b  c  y  c  y  w  c
    3  0  4  x  f  y  c  f  f  f
    5  1  3  e  w  c  w  c  w  w
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data set that that I would like to call in a
I have big data frame with various numbers of columns and rows. I would
We have a small data set and would like to search through it in
I have a large real 1-d data set called r. I would like plot:
I have a 2D distribution of a data set, and I would like to
I have a selection of a huge set of data and I would like
I have a set of controls bound to data, on which I would like
I have a div that I would like to refresh on page load then
I have a data set that looks something like this: Gender | Age |
I have a data set that looks something like this: Gender | Age |

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.