DT中的引用:datatable

问题描述 投票:3回答:1

我正在做一个书本项目,我们有大桌子也包含引用。我们同时输出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

样本reference.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}
}
r r-markdown dt bookdown
1个回答
0
投票

我建议您使用RefManageR程序包呈现引用。

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() ```

或带有链接:

datatable example screenshot

检查data_frame(citation = RefManageR::TextCite(bib = bib, "chambers_2012", .opts = list(style = "html", max.names = 1))) %>% DT::datatable(escape = FALSE) 以获取有关输出格式,链接类型等的更多选项

P.S。无论出于何种原因,第一次调用该函数似乎都没有完全考虑所有给定的选项,因此?BibOptions调用。

© www.soinside.com 2019 - 2024. All rights reserved.