在R中渲染Rmarkdown Stops时创建可执行的ShinyApp之后

时间:2017-09-06 09:42:10

标签: r

我在服务器中有一个闪亮的应用程序。我有以下代码从Markdown(.rmd)文件生成.html文件:

rmarkdown::render("report.rmd", output_file ="www/report.html", output_format = "html_document", quiet = TRUE)

这是降价文件 report.rmd 标题:

---
title: "REPORT OF DC"
date: "This report will introduce you a report of the file for analyzing"
output: html_document

---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, cache=FALSE)
```

如果我想要显示生成的文件,我在UI.R中有这段代码:

shiny::actionButton(inputId='ab3', label="Report", 
                                  icon = icon("th"), 
                                  onclick ="window.open('report.html', '_blank')")

因此,通过RStudio执行我的应用程序工作正常,但是当我使用RInno库生成可执行文件时,生成HTML的选项并不起作用。

require(RInno)

RInno::install_inno()

create_app(app_name = "App", 
           app_dir = "C:/Users/...", 
           include_R = TRUE, 
           R_version = "3.4.0",
           pkgs=c("shiny","shinydashboard","knitr", "data.table", "tools", "stringr", 
                  "lubridate", "readxl","DT","markdown","rmarkdown","xtable",
                  "htmltools","devtools","shinyjs","RMySQL"),
           remotes     = c("jbkunst/highcharter") # GitHub packages
 )
compile_iss() 

1 个答案:

答案 0 :(得分:1)

感谢StéphaneLaurent的评论,我来到了这个解决方案:

首先,我检查了是否安装了pandoc,并在R:

中执行此操作
pandoc.location <- Sys.which("pandoc")
if(pandoc.location == ""){
    print("pandoc not available")
}else{
    print("pandoc available")
}

我意识到它没有安装,所以我必须安装它执行以下代码:

# installing/loading the package:
if(!require(installr)) { install.packages("installr"); require(installr)} #load/ install+load installr

# Installing pandoc
install.pandoc()

最后,我更改了我的函数creat_app添加include_Pandoc = TRUE

create_app(app_name = "App", 
           app_dir = "C:/Users/...",
           include_Pandoc = TRUE,
           include_R = TRUE, 
           R_version = "3.4.0",
           pkgs=c("shiny","shinydashboard","knitr", "data.table", "tools", "stringr", 
                  "lubridate", "readxl","DT","markdown","rmarkdown","xtable",
                  "htmltools","devtools","shinyjs","RMySQL"),
           remotes     = c("jbkunst/highcharter") # GitHub packages
 )

这就是它的完美运作!