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

  • Home
  • SEARCH
  • 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 9128935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:37:59+00:00 2026-06-17T07:37:59+00:00

I have been struggling with how to select ONLY duplicated rows of data.frame in

  • 0

I have been struggling with how to select ONLY duplicated rows of data.frame in R.
For Instance, my data.frame is:

age=18:29
height=c(76.1,77,78.1,78.2,78.8,79.7,79.9,81.1,81.2,81.8,82.8,83.5)
Names=c("John","John","John", "Harry", "Paul", "Paul", "Paul", "Khan", "Khan", "Khan", "Sam", "Joe")
village <- data.frame(Names, age, height)

 Names age height
 John  18   76.1
 John  19   77.0
 John  20   78.1
 Harry  21   78.2
 Paul  22   78.8
 Paul  23   79.7
 Paul  24   79.9
 Khan  25   81.1
 Khan  26   81.2
 Khan  27   81.8
 Sam  28   82.8
 Joe  29   83.5

I want to see the result as following:

Names age height
John  18   76.1
John  19   77.0
John  20   78.1
Paul  22   78.8
Paul  23   79.7
Paul  24   79.9
Khan  25   81.1
Khan  26   81.2
Khan  27   81.8

Thanks for your time…

  • 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-17T07:38:01+00:00Added an answer on June 17, 2026 at 7:38 am

    A solution using duplicated twice:

    village[duplicated(village$Names) | duplicated(village$Names, fromLast = TRUE), ]
    
    
       Names age height
    1   John  18   76.1
    2   John  19   77.0
    3   John  20   78.1
    5   Paul  22   78.8
    6   Paul  23   79.7
    7   Paul  24   79.9
    8   Khan  25   81.1
    9   Khan  26   81.2
    10  Khan  27   81.8
    

    An alternative solution with by:

    village[unlist(by(seq(nrow(village)), village$Names, 
                      function(x) if(length(x)-1) x)), ]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been struggling with Core Data sigh so I decided to work this
I have been struggling to create a Dropdown list which will display Country names
I have been struggling with the following query: select * from table_name where contains((field1,field2),'S.E.N.S');
I have been struggling with this for a while now. given a set of
I have been struggling with setting up an iOS (Objective-C) app which utilizes the
I have been struggling with this error for more than two hours: error: aggregate
I have been struggling for a few days trying to find out how come
I have been struggling all afternoon trying to get a simple mailto: tag to
I have been struggling with encoding problems in MySQL for a while. I am
I have been struggling to think of some decent uses for things like vectors

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.