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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:29:54+00:00 2026-06-13T06:29:54+00:00

l <- c(a,b,c) m is a 5×2 data frame. C1 is 1:5 , C2

  • 0
l <- c("a","b","c")

m is a 5×2 data frame. C1 is 1:5, C2 is a:e:

m <- data.frame(C1 = 1:5, C2 = letters[1:5], stringsAsFactors = FALSE)

I want to find n, where it contains only those rows of m where m$C2 is in the values stated in l

The resulting n is a 3×2 such that C2 is a:c, i.e.

  C1 C2
1  1  a
2  2  b
3  3  c
  • 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-13T06:29:55+00:00Added an answer on June 13, 2026 at 6:29 am

    One option is to do the matching by hand with %in%:

    m <- data.frame(C1 = 1:5, C2 = letters[1:5], stringsAsFactors = FALSE)
    l <- c("a","b","c")
    
    with(m, m[C2 %in% l, ])
    
    R> with(m, m[C2 %in% l, ])
      C1 C2
    1  1  a
    2  2  b
    3  3  c
    

    Or alternatively via the match() function:

    R> m[with(m, match(C2, l, nomatch = FALSE)), ]
      C1 C2
    1  1  a
    2  2  b
    3  3  c
    

    where the nomatch argument is required to get rid of the NA rows.

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

Sidebar

Related Questions

I have a column filled with data in those rows and i would like
I want to construct a data frame in an Rcpp function, but when I
I'm using R to loop through a data frame, perform a calculation and to
I have to put my database's data in this format (values will differ, obviously),
I have a data frame that has dates, disk reads and disk writes data.
I have the following problem in R: Lets assume the following data frame: a
I'm trying to write the contents of a data frame to an RData file.
I have a data.frame with the following characteristics: +-----------------------------------------+ | earning budget ts total
i have jtable filed with data. i want to create java code for Action
I have a table of data (in this case property rents) and want to

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.