在编写Rhtml文档时,您可以利用<!--rinline x -->在Rhtml文档中编写内联代码。但是,这段代码被包装在<code class="inline knitr">x</code>中,这可能会破坏基本格式。
有没有办法把它完全移除呢?以便只将x写入到文档中。
发布于 2013-03-13 03:15:16
我假设您的意思是只有存储在x中的内容的输出才会写入到文档中。您可以通过将表达式包装在I()中来实现此目的。
比较以下命令输出的差异:
<html>
<head>
<title>Title</title>
</head>
<body>
<p>Test document</p>
<!--rinline x <- 3 -->
<!--rinline x -->
<!--rinline I(x) -->
</body>
</html>这将生成以下正文:
<body>
<p>Test document</p>
<code class="knitr inline">3</code>
3
</body>我们可以看到,第一行代码获得了code标记,而第二行只是将输出直接插入到文档中。
https://stackoverflow.com/questions/15369320
复制相似问题