Jakub,
when I read the remark by Jim Warrell in the article mentioned above I thought meant the following.
Because I don't have your data set I use a map of (part of) Europe as an example,
where I want (again as an example and no political intentions
) to move (nudge)
the text that indicates 'Poland' to another place.
So I
- plot the map with the default nudges (0)
- add the nudges (in x and y direction). They are 0 for all data with an exception for Poland.
To avoid confusion I changed the text for Poland to 'Nudged Poland'
- plot the map again with my own nudges (called
my_nudge_x and my_nudge_y)
library("dplyr")
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library("rnaturalearth")
library("rgeos")
#> Loading required package: sp
#> rgeos version: 0.5-3, (SVN revision 634)
#> GEOS runtime version: 3.8.0-CAPI-1.13.1
#> Linking to sp version: 1.4-1
#> Polygon checking: TRUE
library("ggplot2")
world <- ne_countries(scale = "medium", continent='europe',
returnclass = "sf")
ggplot(data = world) +
geom_sf(aes(fill=admin)) +
coord_sf(xlim = c(-10, 40), ylim = c(35, 70)) +
geom_sf_text(aes(label = admin),size=2,family="sans") +
guides(fill=FALSE)
#> Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
#> give correct results for longitude/latitude data

world2 <- world %>%
mutate(my_nudge_x=ifelse(admin=='Poland',15,0) ,
my_nudge_y=ifelse(admin=='Poland',5,0) ,
admin = ifelse(admin=='Poland','Nudged Poland',admin)
)
ggplot(data = world2) +
geom_sf(aes(fill=admin)) +
coord_sf(xlim = c(-10, 40), ylim = c(35, 70)) +
geom_sf_text(aes(label = admin),size=2,family="sans",
nudge_x=world2$my_nudge_x,nudge_y=world2$my_nudge_y) +
guides(fill=FALSE)
#> Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
#> give correct results for longitude/latitude data

Created on 2020-07-17 by the reprex package (v0.3.0)