I have some sf polygons and would like to dissolve the boundaries of overlapping polygons. In other words I would like to have as a results only two polygons.
This S/O post is probably the most direct solution, assuming the boundaries don't need to be preserved or if working with dual sf objects is not an objection.
In your case - when one of your desired polygon groups seems to have only a single member - you could go by name of the isolated island polygon. Consider this piece of code built on the well known & much loved nc.shp shapefile:
library(sf)
library(dplyr)
shape <- st_read(system.file("shape/nc.shp", package="sf")) # included with sf package
merged_shape <- shape %>%
mutate(is_cnty_ashe = ifelse(NAME == "Ashe", TRUE, FALSE)) %>%
group_by(is_cnty_ashe) %>%
summarise()
plot(merged_shape)
What it does is that it dissolves 100 NC counties to two groups - one containing County Ashe, and the other for the rest of NC. Then it uses this grouping to dissolve boundaries using dplyr::summarise() call.