Shiny.io部署报错:pandoc文档转换失败(错误码99)求助
问题
本地运行正常的Shiny应用,部署到shiny.io后生成HTML报告时出现报错:Error in : pandoc document conversion failed with error 99,应用对应的Rmarkdown代码如下:
--- title: "ROC分析报告" output: html_document: css: styles.css toc: true toc_float: true number_sections: false theme: lumen highlight: textmate class: 'center' params: roc_plot: NA roc_table: NA chatgpt_interpretation: NA chatgpt_interpretationPL: NA sales_text: NA cl_dist_plot: NA cht_int_cls: NA pred_dist_plot: NA cht_pred_cls: NA combined_placeholder: NA chatgpt_int: NA int_text: NA --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) library(ggplot2) library(grid) library(knitr) library(kableExtra) library(htmltools)
1. 引言
htmlEscape(params$chatgpt_int)
2. 结果
htmlEscape(params$sales_text)
注:调用scispace API后,本引言部分将得到补充。
数据质量检查
if (inherits(params$pred_dist_plot, "ggplot")) { print(params$pred_dist_plot) } else { knitr::include_graphics(params$pred_dist_plot) }
htmlEscape(params$cht_pred_cls)
if (inherits(params$cl_dist_plot, "ggplot")) { print(params$cl_dist_plot) } else { knitr::include_graphics(params$cl_dist_plot) }
htmlEscape(params$cht_int_cls)
ROC曲线
if (inherits(params$roc_plot, "ggplot")) { print(params$roc_plot) } else { knitr::include_graphics(params$roc_plot) }
htmlEscape(params$chatgpt_interpretationPL)
性能指标
if (!is.null(params$roc_table)) { knitr::kable(params$roc_table, caption = "表1:ROC分析的性能指标。", format = "html") %>% kable_styling() }
htmlEscape(params$chatgpt_interpretation)
3. 结论
htmlEscape(params$combined_placeholder)
# 解决方案 针对pandoc错误99,可按以下步骤排查修复: - **对齐依赖版本**:本地和shiny.io的R包版本差异可能引发问题,使用`renv`锁定`knitr`、`rmarkdown`、`kableExtra`等核心包的版本后重新部署,或在应用中添加`sessionInfo()`输出对比环境差异。 - **修复CSS文件问题**:若外部`styles.css`未正确上传,改用`includeCSS()`将样式嵌入Rmarkdown,避免路径依赖: ```r # 在setup代码块中添加 includeCSS("styles.css")
或直接将CSS内容写在Rmarkdown的<style>标签中。
- 处理特殊文本内容:所有传入Rmarkdown的文本参数需用
htmltools::htmlEscape()转义,避免特殊字符、HTML标签干扰pandoc转换。 - 验证绘图对象有效性:优先传递
ggplot对象,若使用基础绘图,需在Shiny中提前将绘图保存为临时文件(如png),再将文件路径传入参数,在Rmarkdown中用include_graphics()读取。 - 简化输出配置:暂时移除YAML中
class: 'center'等非必需配置,排查是否为pandoc不兼容的选项导致报错。
内容的提问来源于stack exchange,提问作者Melih Aras
相关产品推荐
相关产品推荐

