Learn R Programming

datamaps

R htmlwidget for datamaps, plot choropleth, overlay arcs and bubbles, customise options, easily interact with Shiny proxies.

Installation

# CRAN release
install.packages("datamaps")

# Development version
devtools::install_github("JohnCoene/datamaps")

Development version includes 2 plugins, add_icons and add_markers.

Info

  • See website for demos.
  • Includes proxies to update the visualisation without re-drawing entire map.
  • See NEWS.md for new features and bug fixes

Shiny Proxies

  • update_bubbles - update bubbles.
  • update_choropleth - update choropleth values.
  • update_labels - update labels.
  • update_legend - update the legend.
  • update_arcs - update arcs by coordinates.
  • update_arcs_name - update arcs by name.
  • delete_map - delete the map.

Examples

Example proxy.

demo

library(shiny)

ui <- fluidPage(

  textInput(
    "from",
    "Origin",
    value = "USA"
  ),
  textInput(
    "to",
    "Destination",
    value = "RUS"
  ),
  actionButton(
    "submit",
    "Draw arc"
  ),
  datamapsOutput("map")
)

server <- function(input, output){

  arc <- reactive({
    data.frame(from = input$from, to = input$to)
  })

 output$map <- renderDatamaps({
   datamaps()
 })

 observeEvent(input$submit, {
   datamapsProxy("map") %>%
     add_data(arc()) %>%
     update_arcs_name(from, to)
 })

}

shinyApp(ui, server)
}

Copy Link

Version

Install

install.packages('datamaps')

Monthly Downloads

5

Version

0.0.3

License

MIT + file LICENSE

Maintainer

John Coene

Last Published

May 14th, 2018

Functions in datamaps (0.0.3)

add_bubbles

Add bubbles
datamaps

Initiate map
set_projection

Set projection
update_labels

Dynamically update labels
add_markers

Add markers
reexports

Objects exported from other packages
add_data

Add data
delete_map

Remove map
add_icons

Add icons
update_choropleth

Dynamically add bubbles
add_graticule

Add graticule
add_labels

Add labels
datamaps-shiny

Shiny bindings for datamaps
config_geo

Configure map
config_bubbles

Configure bubbles
add_legend

Add legend
add_arcs_name

Add arcs
add_arcs

Add arcs
config_arcs

Configure arcs
update_bubbles

Dynamically add bubbles
update_arcs

Dynamically update arcs
add_choropleth

Add choropleth
update_legend

Dynamically update legend