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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:12:04+00:00 2026-06-15T14:12:04+00:00

I have two data frames (A and B), both with a column ‘C’. I

  • 0

I have two data frames (A and B), both with a column ‘C’. I want to check if values in column ‘C’ in data frame A exists in data frame B.

A = data.frame(C = c(1,2,3,4))
B = data.frame(C = c(1,3,4,7))
  • 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-15T14:12:05+00:00Added an answer on June 15, 2026 at 2:12 pm

    Use %in% as follows

    A$C %in% B$C
    

    Which will tell you which values of column C of A are in B.

    What is returned is a logical vector. In the specific case of your example, you get:

    A$C %in% B$C
    # [1]  TRUE FALSE  TRUE  TRUE
    

    Which you can use as an index to the rows of A or as an index to A$C to get the actual values:

    # as a row index
    A[A$C %in% B$C,  ]  # note the comma to indicate we are indexing rows
    
    # as an index to A$C
    A$C[A$C %in% B$C]
    [1] 1 3 4  # returns all values of A$C that are in B$C
    

    We can negate it too:

    A$C[!A$C %in% B$C]
    [1] 2   # returns all values of A$C that are NOT in B$C
    

    If you want to know if a specific value is in B$C, use the same function:

      2 %in% B$C   # "is the value 2 in B$C ?"  
      # FALSE
    
      A$C[2] %in% B$C  # "is the 2nd element of A$C in B$C ?"  
      # FALSE
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data frame with two qualitative variables (Q1, Q2) which are both
I have two data frames with two columns each. The first column is timestamps
I have a data frame with two columns. First column contains categories such as
I have two data frames, Data1 and Data2, that I want to merge based
I have two data frames, one contains numbers, and the second is binary, both
Here are my two data frames, both have the same amount of rows which
Suppose I have two data frame 'df_a' & 'df_b' , both have the same
I have two data frames A and B , both of the same dimensions.
I have a data frame with two columns, and want to create a third
I have two data.frames: pattern <- data.frame(pattern = c(A, B, C, D), val =

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.