how to combine values of a tibble and rename

Hi all,

I am creating my first project and I want to eventually produce a chloropleth map by joining mydata (tibble) and mymap (sf and data.frame). mydata is census data with county names, however some have been split into smaller areas like north and south county_name and mymap only has the whole counties. What is the most convenient way to group the split counties so I can rename them to match the map data (so just count_name) and also to combine the values ? Thanks

Hi @gracie_ss,
Welcome to the RStudio Community Forum.
Check out the {dplyr} package, for example:

mydata %>%
  group _by(country) %>%
  summarise(new_val = sum(old_val))


Hi @gracie_ss

I think you will have more luck if you provide examples of your data and your code, what is called a "reprex" (minimal reproducable example) .

To work with the country names you will probably need to get into string handling. The "stringr" package is the best for this, and is part of the tidyverse (like tibble and sf). This will help you to remove the "north" and "south" part of the names and compare them.

By the way, a tibble is a kind of data.frame.