Description Usage Arguments Examples
Create a map in D3
1 2 |
shape |
A |
projection |
D3 projection to use. |
stroke_col |
Color of shape contours. |
stroke_width |
Width of shape contour in pixels. |
width |
Desired width for output widget. |
height |
Desired height for output widget. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | library( sf )
library( rnaturalearth )
library( r2d3maps )
# Hello world!
world <- st_as_sf(countries110)
d3_map(shape = world)
# Brazil!
brazil <- ne_states(country = "brazil", returnclass = "sf")
d3_map(shape = brazil)
# Italy!
italy <- ne_states(country = "italy", returnclass = "sf")
d3_map(shape = italy)
# Oceania!
oceania <- ne_countries(continent = "oceania", returnclass = "sf")
oceania <- sf::st_crop(oceania, xmin = 112, ymin = -56, xmax = 194, ymax = 12)
d3_map(shape = oceania) %>%
add_tooltip()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.