将参考文献放在 Rmd 的表格中

问题描述

我正在尝试在我的 Rmd 中生成一个包含引用的表格。这位于包含这些和其他参考文献的手稿中。在手稿中,我可以使用 [@xxxx] 好的。我尝试将此作为表中的一列,并使用 gtDatatableFlextable 包但没有成功。

这就是我的 Rmd 的样子

---
title: "test"
author: "David"
date: "27/01/2021"
output: html_document
bibliography: test.bib
---
test[@guan_clinical_2020]

``` {r,echo = F}
library("gt")
gt(dplyr::tibble("study_id" = c(1,2),"lead_author" = c("Guan,Ni","Guan,Liang"),"sample_size" = c(1099,1590),"refs" = c("[@guan_clinical_2020]","[@guan_comorbidity_2020]")))
```

# **References**

test.bib 文件如下所示。

@article{guan_clinical_2020,title = {Clinical {characteristics} of {Coronavirus} {disease} 2019 in {China}},copyright = {copyright © 2020 Massachusetts Medical Society. All rights reserved.},url = {https://www.nejm.org/doi/10.1056/NEJMoa2002032},doi = {10.1056/NEJMoa2002032},abstract = {Original Article from The New England Journal of Medicine — Clinical characteristics of Coronavirus disease 2019 in China},language = {en},urldate = {2020-07-21},journal = {New England Journal of Medicine},author = {Guan,Wei-jie and Ni,Zheng-yi and Hu,Yu and Liang,Wen-hua and Ou,Chun-quan and He,Jian-xing and Liu,Lei and Shan,Hong and Lei,Chun-liang and Hui,David S. C. and Du,Bin and Li,Lan-juan and Zeng,Guang and Yuen,Kwok-Yung and Chen,Ru-chong and Tang,Chun-li and Wang,Tao and Chen,Ping-yan and Xiang,Jie and Li,Shi-yue and Wang,Jin-lin and Liang,Zi-jing and Peng,Yi-xiang and Wei,Li and Liu,Yong and Hu,Ya-hua and Peng,Peng and Wang,Jian-ming and Liu,Ji-yang and Chen,Zhong and Li,Gang and Zheng,Zhi-jian and Qiu,Shao-qin and Luo,Jie and Ye,Chang-jiang and Zhu,Shao-yong and Zhong,Nan-shan}
}

@article{guan_comorbidity_2020,title = {Comorbidity and its impact on 1590 patients with {COVID}-19 in {China}: a nationwide analysis},volume = {55},copyright = {copyright ©ERS 2020. http://creativecommons.org/licenses/by-nc/4.0/This version is distributed under the terms of the Creative Commons Attribution Non-Commercial Licence 4.0.},issn = {0903-1936,1399-3003},shorttitle = {Comorbidity and its impact on 1590 patients with {COVID}-19 in {China}},url = {https://erj.ersjournals.com/content/55/5/2000547},doi = {10.1183/13993003.00547-2020}
}

测试后的参考工作正常,不幸的是我无法让表中的那些工作。

解决方法

--- title: "test" author: "David" date: "27/01/2021" output: html_document bibliography: test.bib --- test[@guan_clinical_2020] ``` {r,echo = F} library("flextable") library("ftExtra") dat <- dplyr::tibble("study_id" = c(1,2),"lead_author" = c("Guan,Ni","Guan,Liang"),"sample_size" = c(1099,1590),"refs" = c("[@guan_clinical_2020]","[@guan_comorbidity_2020]")) dat %>% flextable() %>% colformat_md() %>% autofit() ``` 可能是这里的解决方案:

shell

enter image description here