将参考文献放在 Rmd 的 table 中
Placing literature references in a table in Rmd
我正在尝试在我的 Rmd 中生成一个包含引用的 table。这位于将包含这些和其他参考文献的手稿中。在手稿中,我可以使用 [@xxxx] ok。我尝试将其作为 table 中的一个专栏并使用 gt
、Datatable
和 Flextable
包但没有成功。
这就是我的 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}
}
测试后的参考工作正常,不幸的是我无法让 table 内的参考工作。
ftExtra
可能是这里的解决方案:
---
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()
```
我正在尝试在我的 Rmd 中生成一个包含引用的 table。这位于将包含这些和其他参考文献的手稿中。在手稿中,我可以使用 [@xxxx] ok。我尝试将其作为 table 中的一个专栏并使用 gt
、Datatable
和 Flextable
包但没有成功。
这就是我的 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}
}
测试后的参考工作正常,不幸的是我无法让 table 内的参考工作。
ftExtra
可能是这里的解决方案:
---
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()
```