【发布时间】:2023-04-03 10:39:01
【问题描述】:
我有一个生成 RMarkdown html 报告的 R 包。 .Rmd 文件位于系统库/包目录中。
我想创建一个函数htmlreport() 将html报告保存到指定的输出目录路径。
如果未指定output_path,则该函数应该可以浏览到输出文件夹。
渲染后我还想打开生成的 html 报告。
我不知道该怎么做。似乎输出文件的路径总是相对于 .Rmd 文件。我怎样才能做到这一点?
htmlreport <- function(output_path = NULL){
f <- system.file("inst/rmd", "html_report.Rmd", package = "abc")
if (is.null(outputh_path)) {
output_path <- ?? "Choose output folder" ....??
}
rmarkdown::render(f, output_dir = output_path)
# and open the html report..?
}
【问题讨论】:
标签: r r-markdown knitr