我认为您最简单的选择是将 .bib 文件视为普通文本文件。尝试这个:
raw_text <- readLines("example.bib")
new_text <- gsub("in light of", "CONSIDERING", raw_text)
writeLines(new_text, con="new_example.bib")
内容example.bib
:
% a sample bibliography file
%
@article{small,
author = {Doe, John},
title = {A small paper},
journal = {The journal of small papers},
year = 1997,
volume = {-1},
note = {in light of recent events},
}
@article{big,
author = {Smith, Jane},
title = {A big paper},
journal = {The journal of big papers},
year = 7991,
volume = {MCMXCVII},
note = {in light of what happened},
}
输出new_example.bib
:
% a sample bibliography file
%
@article{small,
author = {Doe, John},
title = {A small paper},
journal = {The journal of small papers},
year = 1997,
volume = {-1},
note = {CONSIDERING recent events},
}
@article{big,
author = {Smith, Jane},
title = {A big paper},
journal = {The journal of big papers},
year = 7991,
volume = {MCMXCVII},
note = {CONSIDERING what happened},
}
一点解释:
BibEntry
对象具有非标准的内部结构,并且在RefManageR
包中提供的功能之外很难使用。一旦你unclass
或将一个对象简化为一个列表,由于对象所需的字段和属性的混合,BibEntry
就很难将其放回格式。bib
(更糟糕的是,bibtex
内部RefManageR
结构并不完全相同,因此很难从一种上下文转换到另一种上下文。)