I have a dataframe with thousands of rows. I would like to generate a separate dataframe per Country using filter. Is there a way I could do this in one command, instead of manually repeating the code per Country?
Country_List <- c("India", "Japan", "Korea")
library(dplyr)
Dat %>% filter(grepl('Japan', Country))
Country | Variable 1 | Variable 2 |
---|---|---|
India | 1 | B |
Japan | 2 | B |
Korea | 2 | C |
India | 1 | D |
Japan | 2 | C |
Korea | 3 | C |
India | 3 | A |
Japan | 2 | A |
India | 1 | A |
Japan | 1 | B |
Korea | 3 | D |
Japan | 2 | B |
Korea | 4 | C |