Cartovl for R makes carto-vl, an open source JavaScript library to create vector-based visualizations on top of mapbox-gl, available within R via the htmlwidgets package.
- The package development is in an early state.
- Please check the examples as a starting point.
You can install the latest version of cartovl from github with:
# install.packages("devtools")
devtools::install_github("crazycapivara/cartovl")
library(sf)
library(geojsonio)
library(cartovl)
nc_geojson <- system.file("shape/nc.shp", package = "sf") %>%
st_read() %>%
geojson_json()
viz_def <- list(
"color: ramp($AREA, [midnightblue, gold])"
)
map <- cartovl() %>%
set_view(-79.89042, 35.23582, 6) %>%
add_layer(nc_geojson, viz_def)
if (interactive()) map