如何在R Markdown中添加URL?

56

我希望在R markdown中引用一个URL链接,我已经尝试了输入"addlink"或者"address <- ....",但都没有成功。请问我该如何在R markdown中添加链接?

谢谢!

编辑: 评论中的OP代码为

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

4
请添加一些代码!!! - Dev
4
http://rmarkdown.rstudio.com/authoring_basics.html - user3710546
我尝试了这个链接:[linked phrase] (http://bit.ly/1EqAdIp),但还是不起作用 :( - Jennifer Liu
3
为什么你总是在 "]" 和 "(" 之间加空格?应该是 "]["。 - user3710546
1
如@Dev所建议,请在您的原始帖子中添加代码。 - user3710546
显示剩余5条评论
5个回答

83

看到@Hao在下面的回答中提到,这必须在正文中,而不是在代码块中:

来自这个绝妙的资源

[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

14
如果您正在使用shiny,您所需做的就是在标记(白色)区域:
[linked phrase](www.bit.ly/1EqAdIp) #no space, no {r}

你可以通过在文本(=标记)中输入超链接来跳转到另一个页面,而不是通过页面的交互部分(~R)。


8

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

解决方案:移除 {r}


2
您可以尝试使用以下代码添加代表主题的URL。
[ggrepel](https://github.com/slowkow/ggrepel)

即:

[topic](url)

1

如果您想在 RMD 中添加内部链接,即从摘要部分引用附录,请参考以下示例:

摘要

在此处链接到附录节的第二个标题

附录

附录的标题2

您需要添加以下内容(请注意,这是区分大小写的,所有字母都是小写的,并且空格用连字符代替):

# summary

**[name of link](#heading-2-of-appendix)**

```{r}
```

# appendix

```{r}
```

## Heading 2 of Appendix

另外请注意,在引用附录中的标题2时,只有一个#,不管要引用的部分所在的标题类型是什么。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接