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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:06:05+00:00 2026-05-31T14:06:05+00:00

I’m a R beginner and having difficulty with the following pretty simple problem; I

  • 0

I’m a R beginner and having difficulty with the following pretty simple problem;
I have two data frames ( All_df, Bad_df) and want to generate a third such that
All_df – Bad_df = Good_df

> All_df
Row# Originator Recipient  Date          Time
4    1          6          2000-05-16   16:15:00
7    2          7          2000-05-16   16:25:00
22   2          4          2000-07-04   18:05:00
25   2          9          2000-08-07   05:23:00
10   3          2          2000-06-17   18:07:00
13   4          8          2000-06-21   06:49:00 

> Bad_df
Row# Originator    Recipient       Date     Time
4    2             6         2000-05-16 16:15:00
7    2             7         2000-05-16 16:25:00
22   6             4         2000-07-04 18:05:00
25   12            9         2000-08-07 05:23:00
10   30            2         2000-06-17 18:07:00
13   32            8         2000-06-21 06:49:00 



I want to generate Good_df  similar to this:

> Good_df
Row#    Originator Recipient       Date     Time
4        1         6               2000-05-16   16:15:00
10       3         2               2000-06-17   18:07:00
13       4         8               2000-06-21   06:49:00 

Essentially I need a function which searches All_df$ Originator for values that appear in Bad_df$ Originator, eliminating any matches before returning the remaining values to the Good_df.

I have tried

Good_df <-subset(All_df, Originator %in% Bad_df$Originator) 

however nrows of each df looks a little off!

> nrow(All_df)
[1] 26,032
> nrow(Bad_df)
[1] 1,452
> nrow(Good_df)
[1] 12,395

Any assistance would be greatly appreciated.

  • 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-31T14:06:07+00:00Added an answer on May 31, 2026 at 2:06 pm

    Quite intuitively,

    Good_df <-subset(All_df, Originator %in% Bad_df$Originator)
    

    gives you the subset of All_df for bad originators. What you want is to negate your filter to get the subset of good (or non-bad) originators, using the ! operator:

    Good_df <-subset(All_df, ! Originator %in% Bad_df$Originator)
    

    If you are uncomfortable with the precedency rule, you can add a set of parenthesis:

    Good_df <-subset(All_df, !(Originator %in% Bad_df$Originator))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I’m a R beginner and having difficulty with the following pretty simple problem; I
I'm having some trouble indexing data.frames in R. I'm an R beginner. I have
I'm a beginner in JSF and I´m having the following problem: I have a
I am a webservice beginner. Is it required to have two different projects having
Being a beginner I am having difficulty to understand the following statement a)If in
I am having a small problem. I am a beginner to iPhone programming so
I am having trouble getting my activity to generate a MotionEvent.ACTION_UP. Probably a beginner's
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
I'm having a beginner problem: bool _isPalindrome(const string& str) { return _isPalindrome(str.begin(), str.end()); //
Having some really weird problem and as beginner with c++ I don't know why.

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.