I have already written a function that helps create a csv.file for each state.
specify.state <- function(type.state) {
new.state <- any.drinking %>%
filter(state == type.state)
write.csv(new.state,paste("any_drinking_", type.state, ".csv"), row.names = FALSE)
}
Since there are 51 states in my data frame, I'm wondering how to run this function for each state at the same time by using dplyr. So I can get 51 different files at the same time.
Thank you very much for helping!