I want to extract certain rows based on 3-4 condition in each row from a large table I do this in "dplyr"
gene1_fixed = gene1 %>% filter(V4 == "intron" & V16 == 'BEL-39_Dmon' & V20 == "ATP8B" & V19 == "106" | V19 == "107") %>%
filter(V4 == "intron" & V16 == 'Gypsy-102_Dmon' & V20 == "Abl" & V19 == "74" | V19 == "169") %>%
filter(V4 == "upstream" & V16 == 'Gypsy-181_Dmon' & V20 == "CG17571") %>%
filter(V4 == "intron" & V16 == 'Gypsy-22_Dmon' & V20 == "CG1632")
this gives me an empty file, while each filter command works separately and returns the result, how can I combine properly these commands?
CodePudding user response:
How about this?
gene1_fixed = gene1 %>%
filter(
(V4 == "intron" & V16 == 'BEL-39_Dmon' & V20 == "ATP8B" & V19 %in% c("106", "107")) |
(V4 == "intron" & V16 == 'Gypsy-102_Dmon' & V20 == "Abl" & V19 %in% c("74", "169")) |
(V4 == "upstream" & V16 == 'Gypsy-181_Dmon' & V20 == "CG17571") |
(V4 == "intron" & V16 == 'Gypsy-22_Dmon' & V20 == "CG1632") |
)