Rmarkdown中的传单地图?

时间:2018-07-30 16:54:38

标签: r ubuntu leaflet markdown r-markdown

我有一个非常简单的应用程序,它可以在Windows机器上运行,但是当我将它放在闪亮的服务器(这是Linux机器)上时,它将无法运行! 知道为什么吗?

该应用正在尝试生成包含传单地图的pdf文档:

app:

library(shiny)
library(dplyr)
library(ggmap)
library(plotGoogleMaps)
library(googleway)
library(rmarkdown)
library(leaflet)


ui <- fluidPage(
   titlePanel("test"),
   sidebarLayout(
      sidebarPanel(
          downloadButton('report')
      ),

      mainPanel(
      )
   )
)

server <- function(input, output, session) {
test <- reactive({
  df=data.frame(-20.42,181.62,"location")
  colnames(df) = c("lng","lat","name")

  results = list(df=df)
  return(results)

    })


output$report <- downloadHandler(
    filename = "report.pdf",
    content = function(file) {
        tempReport <- file.path(tempdir(), "report.Rmd")
        file.copy("report.Rmd", tempReport, overwrite = TRUE)
        params <- list(df=df)
        rmarkdown::render(tempReport, output_file = file,
                          params = params,
                          envir = new.env(parent = globalenv())
        )
    }
)

}
shinyApp(ui = ui, server = server)

.Rmd文件:

---
title: "test"
output:
  pdf_document: 
    keep_tex: yes
  html_notebook: default
params:
  df: NA
---

```{r echo=FALSE, message=FALSE, warning=FALSE,fig.height=10, fig.width=12}

library(leaflet)
library(htmltools)
library(RColorBrewer)
df = params$df
      leaflet(df,option=leafletOptions(zoomControl=FALSE),width = "100%") %>%
      addScaleBar(position = 'topright') %>%
      addProviderTiles("Esri.WorldImagery",group = "Orthophoto") %>%
      addCircles(~lng, ~lat, radius = 50,label = ~as.character(name))%>%
      addPopups(~lng,~lat,  'Mast location')
```

当我按下linux机器上的下载选项卡时,它说:失败-服务器问题和日志文件说:

Error : no applicable method for 'metaData' applied to an object of class "function"

0 个答案:

没有答案