data(Parks)
library(dplyr)
# how many parks in each country?
table(Parks$country)
# how many parks in each US state?
Parks %>%
filter(country=="US") %>%
count(state, sort=TRUE)
# ballparks in NYC
Parks %>%
filter(state=="NY") %>%
filter(city %in% c("New York", "Brooklyn", "Queens"))
# ballparks in Canada
Parks %>%
filter(country=="CA") %>%
count(state, sort=TRUE)
# what are the Canadian parks?
Parks %>%
dplyr::filter(country=="CA")
Run the code above in your browser using DataLab