I am trying to produce a table within my Rmd that includes references. This sits within a manuscript that will contain these and other references. Within the manuscript I'm able to use [@xxxx] ok. I tried this as a column in the table and using the gt
, Datatable
and Flextable
packages with no success.
This is what my Rmd looks like
---
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**
The test.bib file looks like this.
@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}
}
The reference after test works fine, unfortunately I cant get the ones within the table to work.
ftExtra
may be solution here:
---
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()
```