library(ggplot2)
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
require(maps)
## Loading required package: maps
require(viridis)
## Loading required package: viridis
## Loading required package: viridisLite
## 
## Attaching package: 'viridis'
## The following object is masked from 'package:maps':
## 
##     unemp
library(sf)
## Linking to GEOS 3.11.2, GDAL 3.7.2, PROJ 9.3.0; sf_use_s2() is TRUE
library(ggrepel)
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
theme_set(
  theme_void()
  )
map <- read_sf("shp/shp_dunia.shp")

ggplot(map) +
    geom_sf(color = "white", aes(fill = NAME)) +
  theme(legend.position = "none") +
   geom_sf_text(aes(label = NAME), size = 2) 
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

map <- read_sf("shp/shp_dunia.shp")

peta <- ggplot(map) +
    geom_sf(color = "white", aes(fill = NAME)) +
  theme(legend.position = "none") +
  geom_text_repel(aes(label = paste0(NAME," (",Percent,")") , geometry = geometry),
                  stat = "sf_coordinates", size = 3,
                  fun.geometry = sf::st_centroid,
                  max.overlaps=nrow(map),
                  
                   min.segment.length = 0) + scale_radius(range = c(3,6))


peta

map <- read_sf("shp/shp_dunia.shp")

peta <- ggplot(map) +
    geom_sf(color = "white", aes(fill = NAME)) +
  theme(legend.position = "none") +
  geom_text_repel(aes(label = paste0(NAME," (",Freq,")") , geometry = geometry),
                  stat = "sf_coordinates", size = 3,
                  fun.geometry = sf::st_centroid,
                  max.overlaps=nrow(map),
                  
                   min.segment.length = 0) + scale_radius(range = c(3,6))


peta

map <- read_sf("shp/shp_dunia.shp")

peta <- ggplot(map) +
    geom_sf(color = "white", aes(fill = Percent)) +
  geom_text_repel(aes(label = paste0(NAME," (",Freq,")") , geometry = geometry),
                  stat = "sf_coordinates", size = 3,
                  fun.geometry = sf::st_centroid,
                  max.overlaps=nrow(map),
                  
                   min.segment.length = 0) + scale_radius(range = c(3,6))


peta

map <- read_sf("shp/shp_dunia.shp")

peta <- ggplot(map) +
    geom_sf(color = "white", aes(fill = Percent)) +
  geom_text_repel(aes(label = paste0(NAME," (",Freq,")") , geometry = geometry),
                  stat = "sf_coordinates", size = 3,
                  fun.geometry = sf::st_centroid,
                  max.overlaps=nrow(map),
                  
                   min.segment.length = 0) + scale_radius(range = c(3,6)) +
   scale_fill_viridis_c() 


peta

map <- read_sf("shp/shp_dunia.shp")

peta <- ggplot(map) +
    geom_sf(color = "white", aes(fill = NAME)) +
  theme(legend.position = "none") +
  geom_text_repel(aes(label = paste0(NAME," (",Percent,")") , geometry = geometry  ),
                  stat = "sf_coordinates", size = 3) 


peta
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data
## Warning: ggrepel: 9 unlabeled data points (too many overlaps). Consider
## increasing max.overlaps