Paste logical conditions in R -


i have rewriten problem make clearer

i want replace condition var variable in dataframe (dataframe$var) paste or other solution have many condition values(?) (a, b , c in example).

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

i have tried make list(?) of condtion values.

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

and use paste make logical condition

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

but doesn't work

help please =)

marcus

heed fortune(106):

> fortune(106)  if answer parse() should rethink question.    -- thomas lumley       r-help (february 2005) 

so encourage rethink you're trying do...

i guess use match or %in% achieve desired result, haven't told you're trying 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 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -