Displaying 3 results from an estimated 3 matches for "pd_t1".
2016 Apr 22
0
subset by multiple letters condition
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, fixed=TRUE)
hast2 <- grepl("t2", Command, fixed=TRUE)
> Command[hast1]
[1] "_localize_t1_seq" "_localize_PD_t1"
> Command[hasPD]
[1] "_localize_PD...
2016 Apr 22
2
subset by multiple letters condition
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 unknown. I don't know how to use grep for all these conditions.
'data.frame': 36919
2016 Apr 23
1
subset by multiple letters condition
...v> wrote:
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, fixed=TRUE)
hast2 <- grepl("t2", Command, fixed=TRUE)
> Command[hast1]
[1] "_localize_t1_seq" "_localize_PD_t1"
> Command[hasPD]
[1] "_localize_P...