如何将URL添加到R markdown?

时间:2015-04-22 04:36:42

标签: r hyperlink knitr r-markdown

我想将一个URL链接引用到R markdown,我已经尝试了输入,例如" addlink" 或"地址< - ...." 它们都不起作用。 如何在R markdown中添加链接?

谢谢!

编辑来自评论的代码是

   {r} [linked phrase] (www.bit.ly/1EqAdIp)

3 个答案:

答案 0 :(得分:29)

注意@ Hao的答案,这必须在正文中,而不是在代码块中:

来自this fabulous resource

[I'm an inline-style link](https://www.google.com)

[I'm an inline-style link with title](https://www.google.com "Google's Homepage")

[I'm a reference-style link][Arbitrary case-insensitive reference text]

[I'm a relative reference to a repository file](../blob/master/LICENSE)

[You can use numbers for reference-style link definitions][1]

Or leave it empty and use the [link text itself]

Some text to show that the reference links can follow later.

[arbitrary case-insensitive reference text]: https://www.mozilla.org
[1]: http://slashdot.org
[link text itself]: http://www.reddit.com

答案 1 :(得分:5)

您不应将超链接放在R代码块中。 xxx是Markdown语法。如果你把它放在{r}之后,knitr / rmarkdown会将它视为R代码的一部分,当然,R会产生错误信息。

解决方案:删除{r}

答案 2 :(得分:4)

如果您使用闪亮,您需要做的就是在标记(白色)区域:

[linked phrase](www.bit.ly/1EqAdIp) #no space, no {r}

这样您就可以在文本(=标记)处输入超链接,而不是页面的交互部分(~R)。