currently I have a data frame that is segmented based on state, so for example:
STATE
1 Connecticut
2 Maine
3 New York
4 Pennsylvania
I want to be able to segment these states based on region, and would want a column based on that:
STATE REGION
1 Connecticut New England
2 Maine New England
3 New York Mid-Atlantic
4 Pennsylvania Mid-Atlantic
Currently, I have this:
ne <- c("Connecticut", "Maine", "Massachusetts", "New Hampshire", "Rhode Island", "Vermont")
values <- c("New England")
df$REGION <- values[match(jails_cleaned$STATE, ne)]
midatlantic <- c("New Jersey", "New York", "Pennsylvania")
values2 <- c("Mid-Atlantic")
df$REGION <- values[match(df$STATE, midatlantic)]
but when running this, it only matches the New England values and not Mid-Atlantic.