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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:39:42+00:00 2026-05-29T10:39:42+00:00

I need to extract parts of a dataframe, using the values which I have

  • 0

I need to extract parts of a dataframe, using the values which I have generated previously. For example, I have the following data:

a<-c(1,2,3,4,6,7,10,12,17,20)
df1<-data.frame(a)

I then want to exclude these values (in “a” in df1) from df2 when they appear in column b:

b<-c(1,2,3,4,5,6,6,6,7,8,9,10,11,11,11,12,13,14,14:20)
c<-c(1:25)
df1<-data.frame(b,c)

So, I should be left with a dataframe with rows 5,8,9,11 etc…

Can anyone help me out with the code to remove these values from my dataframe (df1).

Many thanks.

  • 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-29T10:39:43+00:00Added an answer on May 29, 2026 at 10:39 am

    subset() will be a good friend to you for this sort of thing:

    subset(df1, !b %in% a)
    

    (The sub-expression b %in% a tests each element of b to determine whether or not it is in a, returning a vector of TRUEs and FALSEes. !b %in% a just negates/flips those Boolean values, so that you end up with a logical vector indexing with TRUEs the rows of df1 that you would like to keep (i.e. those that don’t appear in a).)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to extract parts of a string using regex in Python. I'm good
I have HTML that I need to extract a part number from, the HTML
I need to extract data from a .mpp file on the network and combine
The problem: I often need to select a set of variables from a data.frame
Let's be honest, I'm struggling with the regular expression I need to extract parts
I have a datasource in SmartGWT. How do i extract data from it? I
I need to extract the first part of postcode for search calculation using a
I need to extract large amounts of data from a variety of HTML files,
I need to extract some data from a webpage with php. The part that
Let me first describe my situation. I have a list of Hex values, which

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.