这可能非常简单,但我似乎在文档中找不到它。我不想将生成的图像嵌入到HTML文件本身。
因此,基本上我希望knit2html()生成一个包含独立图像文件的超文本标记语言文件(然后将这些图像文件链接到/显示在超文本标记语言中)。基本行为是脚本将图像作为base64字符串嵌入。这样做的问题是,在IE中,大图像不会显示(即似乎丢失了)。知道如何将图像从HTML输出中分离出来吗?
我的示例.Rmd文件('knit.Rmd'):
```{r}
图(3)
和我的.R文件从下面的代码中生成超文本标记语言:
library(knitr)
knit2html('knit.Rmd')
此示例生成一个带有嵌入base64字符串的绘图的超文本标记语言。
发布于 2013-02-14 16:57:18
如果您查看knit2html
的帮助页面,您将看到:
This is a convenience function to knit the input markdown source and
call ‘markdownToHTML()’ in the ‘markdown’ package to convert the
result to HTML.
然后查看markdownToHTML
帮助页面,发现有以下参数:
options: options that are passed to the renderer. see
‘markdownHTMLOptions’.
所以你看了一下markdownHTMLOptions
(仍然没有丢失?)并查看以下选项:
‘'base64_images'’ Any local images linked with the ‘'<img>'’ tag
to the output HTML will automatically be converted to base64
and included along with output.
使用以下命令,您应该会看到系统上的默认选项:
R> markdownHTMLOptions(default=TRUE)
[1] "use_xhtml" "smartypants" "base64_images" "mathjax"
[5] "highlight_code"
因此,您可以尝试使用以下命令编织您的markdown文件:
knit2html("knit.Rmd", options=c("use_xhtml","smartypants","mathjax","highlight_code"))
不过,没有经过测试。
发布于 2017-08-11 16:27:53
您可以只将self_contained: no
添加到.Rmd标头的输出选项中。例如:
---
title: "Data visualisation with ggplot"
output:
html_document:
self_contained: no
toc: yes
toc_float: yes
---
发布于 2013-02-14 16:56:40
这不是knitr
做的,knitr
只是在运行R
块之后生成一个修改过的标记文件。因此,您需要查看markdown
包的帮助来找出...
这是base64_images
选项。咖啡还没有生效,所以我还没有弄清楚如何设置/重置单独的降价选项,但清除它们对我来说是可行的:
> knit2html("foo.Rmd",options="")
生产
<p><img src="figure/unnamed-chunk-1.png" alt="plot of chunk unnamed-chunk-1"> </p>
在foo.html
中。
如果清除所有这些选项会破坏其他东西,那么请阅读markdownHTMLOptions
。
https://stackoverflow.com/questions/14870589
复制相似问题