Guardar mapas de folleto en R brillante
He creado una aplicación donde el usuario puede modificar un mapa de folleto y me gustaría usar este mapa en un informe pdf. Tengo 1. paquetes de folletos instalados, webshot y htmlwidget 2. instalé PhantomJS
a continuación hay una versión simplificada del código
servidor.R:
library(shiny)
library(leaflet)
library(htmlwidgets)
library(webshot)
shinyServer(function(input, output, session) {
output$amap <- renderLeaflet({
leaflet() %>%
addProviderTiles("Stamen.Toner",
options = providerTileOptions(noWrap = TRUE, reuseTiles=TRUE))
})
observe({
leafletProxy("amap") %>%
clearShapes() %>%
addCircles(lng = c(22,-2), lat = c(42,65))
})
observeEvent(input$saveButton,{
themap<- leafletProxy("amap")
saveWidget(themap, file="temp.html", selfcontained = F)
webshot("temp.html", file = "Rplot.png",
cliprect = "viewport")
})
})
ui.R:
fluidPage(
leafletOutput("amap", height="600px", width="600px"),
br(),
actionButton("saveButton", "Save")
)
Me sale este mensaje de error:
Advertencia: Error en system.file: 'package' debe ser de longitud 1 Stack trace (el más interno primero): 73: system.file 72: readLines 71: paste 70: yaml.load 69: yaml :: yaml.load_file 68: getDependency 67: widget_dependencies 66: htmltools :: attachDependencies 65: toHTML 64: saveWidget 63: observeEventHandler [C: \ R files \ test / server.R # 24] 1: shiny :: runApp
cuando el botón guardar está activado. savewidget funciona bien cuando defino el botón guardar de esta manera:
observeEvent(input$saveButton,{
themap<-leaflet() %>%
addProviderTiles("Stamen.Toner",
options = providerTileOptions(noWrap = TRUE, reuseTiles=TRUE))
saveWidget(themap, file="temp.html", selfcontained = F)
webshot("temp.html", file = "Rplot.png",
cliprect = "viewport")
})
Pero realmente quiero los cambios que el usuario hace en la captura web. ¿Alguien puede ayudar?