使用 R 包 RefManageR 调整文本引用
Adjust text citation using R package RefManageR
我正在尝试使用 R
程序包 RefManageR
管理参考书目,如下所示。
library(RefManageR)
file.name <- system.file("Bib", "RJC.bib", package="RefManageR")
bib <- ReadBib(file.name)
BibOptions(check.entries = FALSE, bib.style = "authoryear", max.names = 1,
style = "citation", bibpunct = c("(",")","(",")",";",","))
Cite(bib, c("jennings2013bayesian", "ritchie2012novel"))
[1] "(Jennings, et al., 2013; Ritchie, et al., 2012)"
如何调整引文中的标点符号以获得以下所需的引文(et al 之前没有逗号)?
[1] "(Jennings et al., 2013; Ritchie et al., 2012)"
bibpunct
参数似乎没有可用的选项。
您可以使用像这样的简单正则表达式:
, (?=et al\.)
# match a comma, only when it is followed by et al.
这需要用单个 space 替换,然后参见 a demo on regex101.com。
在 R
:
ref <- c("(Jennings, et al., 2013; Ritchie, et al., 2012)")
(ref <- gsub(", (?=et al\.)", " ", ref, perl=TRUE))
这产生
[1] "(Jennings et al., 2013; Ritchie et al., 2012)"
我正在尝试使用 R
程序包 RefManageR
管理参考书目,如下所示。
library(RefManageR)
file.name <- system.file("Bib", "RJC.bib", package="RefManageR")
bib <- ReadBib(file.name)
BibOptions(check.entries = FALSE, bib.style = "authoryear", max.names = 1,
style = "citation", bibpunct = c("(",")","(",")",";",","))
Cite(bib, c("jennings2013bayesian", "ritchie2012novel"))
[1] "(Jennings, et al., 2013; Ritchie, et al., 2012)"
如何调整引文中的标点符号以获得以下所需的引文(et al 之前没有逗号)?
[1] "(Jennings et al., 2013; Ritchie et al., 2012)"
bibpunct
参数似乎没有可用的选项。
您可以使用像这样的简单正则表达式:
, (?=et al\.)
# match a comma, only when it is followed by et al.
这需要用单个 space 替换,然后参见 a demo on regex101.com。
在
R
:
ref <- c("(Jennings, et al., 2013; Ritchie, et al., 2012)")
(ref <- gsub(", (?=et al\.)", " ", ref, perl=TRUE))
这产生
[1] "(Jennings et al., 2013; Ritchie et al., 2012)"