Hola, eso lo puedes hacer con el siguiente código:
library("geojsonio")
library("ggplot2")
library("rgdal")
library("rgeos")
library("maptools")
library("ggrepel")
library("sf")
library("mxmaps")
df_mxstate_2020$value <- df_mxstate_2020$indigenous_language /
df_mxstate_2020$pop * 100
p <- mxstate_choropleth(df_mxstate_2020,
num_colors = 1,
title = "Percentage of the population that speaks\nan indigenous language",
legend = "%")
data("mxstate.topoJSON")
data("df_mxstate_2020")
tmpdir <- tempdir()
# have to use RJSONIO or else the topojson isn't valid
write(RJSONIO::toJSON(mxstate.topoJSON), file.path(tmpdir, "state.topojson"))
states <- topojson_read(file.path(tmpdir, "state.topojson"))
# convert to SpatialPolygonsDataFrame
states <- as_Spatial(states)
# make sure the coordinates of the labels are in the correct order
df_mxstate_2020 <- cbind(df_mxstate_2020,
data.frame(lon = coordinates(states[match(df_mxstate_2020$region, states$id),])[,1],
lat = coordinates(states[match(df_mxstate_2020$region, states$id),])[,2]))
df_mxstate_2020$group <- df_mxstate_2020$state_abbr
df_mxstate_2020$label <- sample(1:7, 32, replace = TRUE)
p + geom_text_repel(data = df_mxstate_2020, aes(lon, lat, label = label), size = 3,
box.padding = unit(0.1, 'lines'), force = 0.1)
La parte importante del código son las dos últimas líneas donde asigno el valor de la columna label