Skip to content

Latest commit

 

History

History
81 lines (59 loc) · 1.33 KB

README.R.md

File metadata and controls

81 lines (59 loc) · 1.33 KB
title author output
Datamaps
Ramnath Vaidyanathan
html_document

NOTE: This repo is just for testing purposes

This is an htmlwidgets binding for the datamaps package.

Simple Map

World Map

library(datamaps)
datamaps()

US Map

datamaps(scope = 'usa')

Shiny App

library(shiny)
ui = bootstrapPage(
  selectInput('def_fill', 'Select Color', c('blue', 'green')),
  datamapsOutput('mymap', 800, 400)
)

server = function(input, output, session){
  output$mymap <- renderDatamaps(
    datamaps(
      fills = list(defaultFill = input$def_fill)
    )
  )
}

runApp(list(ui = ui, server = server), launch.browser = rstudio::viewer)

Map with External Data

datamaps(
  scope = 'pcs', 
  geographyConfig = list(dataUrl = 'data/pcs.json'), 
  width = 900, height = 800
)

Shiny App with External Data

library(shiny)
ui = bootstrapPage(
  selectInput('def_fill', 'Select Color', c('blue', 'green')),
  datamapsOutput('mymap', 900, 800)
)

server = function(input, output, session){
  output$mymap <- renderDatamaps(
    datamaps(
      scope = 'pcs', 
      geographyConfig = list(dataUrl = 'data/pcs.json'),
      fills = list(defaultFill = input$def_fill)
    )
  )
}

runApp(list(ui = ui, server = server), launch.browser = rstudio::viewer)