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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:55:32+00:00 2026-05-18T08:55:32+00:00

I have now rewriten my problem to make it clearer I want to replace

  • 0

I have now rewriten my problem to make it clearer

I want to replace a condition like this where var is a variable in dataframe (dataframe$var) with a paste or other solution as I do have so many condition values(?) (a, b and c in my example).

subdataframe<-dataframe[var=="a"|var=="b"|var=="c",]

I have tried to make a list(?) of the condtion values.

sample<-c("a","b","c")

And to then use paste to make the logical condition

subdataframe<-dataframe[paste("var",sample,sep="==",collapse="|"),]

But that doesn’t work

Help please =)

Marcus

  • 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-18T08:55:33+00:00Added an answer on May 18, 2026 at 8:55 am

    Heed fortune(106):

    > fortune(106)
    
    If the answer is parse() you should usually rethink the question.
       -- Thomas Lumley
          R-help (February 2005)
    

    So I would encourage you to rethink what you’re trying to do…

    I would guess that you could use match or %in% to achieve your desired result, but you haven’t told us what you’re trying to do.

    > sample <- c("a","b","c")
    > var <- c("a","d","c")
    > eval(parse(text=paste("var==",sample,"",sep="'",collapse="|")))
    [1]  TRUE FALSE  TRUE
    > var %in% sample
    [1]  TRUE FALSE  TRUE
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say currently I have url like : http://mydomain.com/showpost.php?p=123 Now I want to make it
This problem has bugged me so many times and i have now decided to
Okey, so this is my problem. I want to use mod_rewrite to make nice
I have now been stuck at this for some time so I though to
What I have now (which successfully loads the plug-in) is this: Assembly myDLL =
I have the following problem: I have 3 tables: If you want to create
im having this problem...i wonder if any of you have any ideas how to
I have now 1gb ram at work(i hope that will change soon) and jboss
I have now worked on two different teams that use the Agile/Scrum approach in
I have now seen 2 methods for determining if an argument has been passed

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.