我正在用这个 rmd 创建一个 html 文件
---
title: "test"
author: "me"
date: '`r Sys.Date()`'
output: html_document
---
```{r}
data(HairEyeColor)
rpivotTable::rpivotTable(data = HairEyeColor
, rows = "Hair"
,cols="Eye"
, vals = "Freq"
, aggregatorName = "Sum"
, rendererName = "Table"
, width="100%"
, height="400px")
```
和
rmarkdown::render( input = 'file.RMD' , output_file = 'file.html'
, output_format= html_document( self_contained=TRUE), clean = FALSE
, quiet = FALSE )
输出没问题,但我需要markdown文件(file.md)稍后重新创建html文件(无法访问数据)
rmarkdown 生成两个 md 文件 [file.knit.md] 和 [file.utf8.md] 但是当我渲染这两个文件时,file.html 中缺少 htmlwidget。
rmarkdown::render( input = 'file.utf8.md' , output_file = 'file.html'
, output_format= html_document( self_contained=TRUE) )
对 pandoc 的 rmarkdown 调用有一个 [--include-in-header] 参数指向一个带有小部件依赖项的临时文件,但我没有找到在呈现 md 文件时包含它的方法(即 --include-in-header /tmp/Rtmp1M0RpP/rmarkdown-str1a169e14827.html")
下面我粘贴了来自 rmarkdown 的 pandoc 调用,但同样,单独执行此命令会生成一个没有 htmlwidget 的 html 文件。
/usr/bin/pandoc +RTS -K512m -RTS file.utf8.md
--to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash
--output test._0021.html --smart --email-obfuscation none --self-contained --standalone
--section-divs --template /home/bergel/R/x86_64-pc-linux-gnu-library/3.3/rmarkdown/rmd/h/default.html
--variable 'theme:bootstrap' --include-in-header /tmp/RtmpqpGfD1/rmarkdown-str19b5232f45d7.html
--mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
--no-highlight --variable highlightjs=/home/bergel/R/x86_64-pc-linux-gnu-library/3.3/rmarkdown/rmd/h/highlight
--variable navigationjs=/home/bergel/R/x86_64-pc-linux-gnu-library/3.3/rmarkdown/rmd/h/navigation-1.1
我想要带有交互式 htmlwidget 的 html 文件,而不是小部件的 png。使用下面的代码,我可以生成一个 file.md,然后它可以呈现一个 html 文件,但使用小部件的 png,而不是交互式 js 小部件。
rmarkdown::render( input = 'file.RMD' , output_file = 'file.md'
, output_format= md_document( ) )
我发现这个问题与这个问题有关: Extract html dependencies for .Rmd file ( contains htmlwidgets)