Re: [R] subset by multiple letters condition

2016-04-23 Thread Adams, Jean
This is quite a different question. I suggest you start a new post with a new subject line for this. And I suggest you include code for an example plot that you want to use. Otherwise, you might look here for some ideas on how to control colors in a scatter plot using base r, http://stackoverflo

Re: [R] subset by multiple letters condition

2016-04-23 Thread ch.elahe via R-help
Thanks Jean, Does anyone know how to set these [hast1] and [hast2] as the colors of a plot? On Friday, April 22, 2016 7:39 AM, "Adams, Jean" wrote: You can use the grepl() function to give you logicals for each criterion, then combine them as needed. For example: # example version of Co

Re: [R] subset by multiple letters condition

2016-04-22 Thread Adams, Jean
You can use the grepl() function to give you logicals for each criterion, then combine them as needed. For example: # example version of Command Command <- paste0("_localize_", c("PD","t2","t1_seq", "abc", "xyz", "PD_t1")) hasPD <- grepl("PD", Command, fixed=TRUE) hast1 <- grepl("t1", Command, f

Re: [R] subset by multiple letters condition

2016-04-22 Thread Giorgio Garziano
You may investigate a solution based on regular expressions. Some tutorials to help: http://www.regular-expressions.info/rlanguage.html http://www.endmemo.com/program/R/grep.php http://biostat.mc.vanderbilt.edu/wiki/pub/Main/SvetlanaEdenRFiles/regExprTalk.pdf https://rstudio-pubs-static.s3.ama

[R] subset by multiple letters condition

2016-04-22 Thread ch.elahe via R-help
Hi all, I have a data frame df and I want to do subset based on several conditions of letters of the names in Command.1)if the names contain PD 2)if the names contain t1 3)if the names contain t2 4)if the names contain t1 and PD 5)if the names contain t2 and PD 6)otherwise the names would be