I have a list of gene names that I am trying to filter out of a larger data set using grepl. For example:
gene_list <- c(geneA, geneB, geneC)
data <- c(XXXgene1, XXXgene2, XXXgeneF, XXXgeneA, XXXgeneB)
select_grepl <- data %>% filter(grepl(c(gene_list), data)==T)
I have tried the grepl code above but since the pattern is > 1 they only use the first geneA to search within the string. If I change c(gene_list) to a single pattern like "geneA", then the code works. Is there another solution?
Aucun commentaire:
Enregistrer un commentaire