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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:56:56+00:00 2026-06-16T00:56:56+00:00

Dear stackoverflow experts, I have two tables table1<-read.table(table1.txt,header=TRUE) table2<-read.table(table2.txt,header=TRUE) I want to select from

  • 0

Dear stackoverflow experts,

I have two tables

table1<-read.table("table1.txt",header=TRUE)
table2<-read.table("table2.txt",header=TRUE)

I want to select from table 1 all of the values that match values of the first column of table 2. I have try sqldf, but I´m not sure of the syntax,

selection<-sqldf("SELECT *, column1 from table1 WHERE column1 like column2 from table2")

Any suggestion?

  • 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-16T00:56:59+00:00Added an answer on June 16, 2026 at 12:56 am

    You can try the following:

     table1[sapply(table1, function(x) x %in% table2[, 1, drop=FALSE])]
    

    What happens here is that the sapply statement is returning a logical list indicating which elements of table1 are in table2‘s first column. We are then using that logical vector to index table1

      # to see this more clearly, try the following line, 
      # which is what is being used to index table1
      sapply(table1, function(x) x %in% table2[, 1, drop=FALSE])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dear stackoverflow members, I have a small problem, I want to replace some characters
Dear Stackoverflow members I have a recursive CTE query like this: DECLARE @Level TABLE
Dear experts, I was trying to dynamically generate DOM elements using JS. I read
Dear Stackoverflow Developers i have to load image as an icon to jmenu from
Dear Masters in stackoverflow, I want to build an app, Spring-WS on server side,
dear all..i have a table it looks like: Name version DDX 01 DTX 05
Dear gods of Stackoverflow Let's say I have a MySQL query that selects a
Hello dear users of Stackoverflow. I have a project made in Winforms where i
Dear stackoverflow community, I have a simple menu that have to be dynamics. With
Dear StackOverflow community, I have a dataset from my university projects I am trying

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.