2017-09-06 41 views
2

渲染Rmarkdown停止时可执行ShinyApp后我有光泽的应用,其中在server.RI有以下代码来生成从降价(.rmd)文件中的HTML文件:创建中的R

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

也许你必须设置路径为pandoc。我会尝试'Sys.setenv(RSTUDIO_PANDOC =“path/to/pandoc”)例如在'global.R'中。 –

+2

...或在'create_app'中试试'include_Pandoc = TRUE'选项 –

回答

1

感谢斯特凡纳·洛朗意见,我来到了这个解决方案:

首先,我检查,如果我有pandoc装R中执行此:

pandoc.location <- Sys.which("pandoc") 
if(pandoc.location == ""){ 
    print("pandoc not available") 
}else{ 
    print("pandoc available") 
} 

我意识到:这不是什么t安装,所以我不得不安装它执行以下代码:

# 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 
) 

而这就是它的完美运作!