DT 中的引文:数据表

Jan*_*rup 6 r r-markdown dt bookdown

我正在做一个 bookdown 项目,其中我们有包含引文的大表。我们同时输出 html 和 pdf。问题是我找不到在表格中呈现引文的方法。

对于 PDF 输出,此乳胶解决方法有效:https : //github.com/haozhu233/kableExtra/issues/214 但是,对于我一直在使用的 html 输出DT:datatable,我无法找到使引用呈现的方法。

有没有办法在表格中获得降价解析的引文?

降价示例:

---
title: "Untitled"
output: html_document
bibliography: ["references.bib"]
---


In text citation [@chambers_2012].


A plan data.frame can render the reference if inserted as text that markdown can parse.

```{r, results='asis'}
library(dplyr)
library(DT)

data_frame(citation = "[@chambers_2012]")

```

But not in a DT.

```{r, results='asis'}
library(dplyr)
library(DT)

data_frame(citation = "[@chambers_2012]") %>% datatable()

```



# bibliography
Run Code Online (Sandbox Code Playgroud)

示例参考.bib

@article{chambers_2012,
title = {A cross-platform toolkit for mass spectrometry and proteomics.},
author = {Chambers, Matthew C and Maclean, Brendan and Burke, Robert and Amodei, Dario and Ruderman, Daniel L and Neumann, Steffen and Gatto, Laurent and Fischer, Bernd and Pratt, Brian and Egertson, Jarrett and Hoff, Katherine and Kessner, Darren and Tasman, Natalie and Shulman, Nicholas and Frewen, Barbara and Baker, Tahmina A and Brusniak, Mi-Youn and Paulse, Christopher and Creasy, David and Flashner, Lisa and Kani, Kian and Moulding, Chris and Seymour, Sean L and Nuwaysir, Lydia M and Lefebvre, Brent and Kuhlmann, Frank and Roark, Joe and Rainer, Paape and Detlev, Suckau and Hemenway, Tina and Huhmer, Andreas and Langridge, James and Connolly, Brian and Chadick, Trey and Holly, Krisztina and Eckels, Josh and Deutsch, Eric W and Moritz, Robert L and Katz, Jonathan E and Agus, David B and {MacCoss}, Michael and Tabb, David L and Mallick, Parag},
pages = {918-920},
url = {http://www.nature.com/doifinder/10.1038/nbt.2377},
year = {2012},
month = {oct},
urldate = {2018-01-13},
journal = {Nature Biotechnology},
volume = {30},
number = {10},
issn = {1087-0156},
doi = {10.1038/nbt.2377},
pmid = {23051804},
pmcid = {PMC3471674},
f1000-projects = {shared citations}
}
Run Code Online (Sandbox Code Playgroud)

gio*_*mai 4

我建议您使用该包呈现引文RefManageR。

```{r}
library("RefManageR")
bib <- ReadBib(file = "references.bib")

invisible(data_frame(citation = RefManageR::TextCite(bib = bib)))
```


```{r}
data_frame(citation = RefManageR::TextCite(bib = bib,
                                           "chambers_2012",
                                           .opts = list(max.names = 1))) %>%
  DT::datatable()
```
Run Code Online (Sandbox Code Playgroud)

数据表示例截图

或者通过链接:

data_frame(citation = RefManageR::TextCite(bib = bib,
                                           "chambers_2012",
                                           .opts = list(style = "html",
                                                        max.names = 1))) %>%
  DT::datatable(escape = FALSE)
Run Code Online (Sandbox Code Playgroud)

查看?BibOptions有关输出格式、链接类型等的更多选项。

PS无论出于何种原因,第一次调用该函数似乎没有完全考虑给定的所有选项,因此该invisible()调用。