I downloaded the shapefile data from US census bureau, class is both dataframe, am trying to merge subregion in both, so I have changed NAME in the previous counties which is reflecting from the names lines of code. However, merging would not work, I have explored all possible merging function.
class(iowa_map)
class(data)
Check column names used in left_join
names(iowa_map)
names(data)
Check for missing values in merging columns
sum(is.na(iowa_counties$NAME))
sum(is.na(data$subregion))
iowa_map_sf <- st_as_sf(iowa_map)
merged_data <- left_join(iowa_map_sf, data, by = c("subregion" = "subregion"))
#merged_data <- merge(iowa_map_sf, data, by.x = "subregion", by.y = "subregion", all.x = TRUE)
merged_data