gpt4 book ai didi

r - 在 R 中渲染 Rmarkdown 停止时创建可执行的 ShinyApp 后

转载 作者:行者123 更新时间:2023-12-04 12:19:59 25 4
gpt4 key购买 nike

我有一个 Shiny 的应用程序,在 server.R 中我有以下代码从 Markdown (.rmd) 文件生成一个 .html 文件:

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

这是 Markdown 文件 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()

最佳答案

感谢 Stéphane Laurent 的评论,我找到了这个解决方案:

首先,我检查了我是否安装了 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
)

这就是它完美运行的全部内容!

关于r - 在 R 中渲染 Rmarkdown 停止时创建可执行的 ShinyApp 后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46071862/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com