【问题标题】:Encoding problems reading .bib into R using RefManageR使用 RefManageR 将 .bib 读入 R 的编码问题
【发布时间】:2018-11-19 16:21:44
【问题描述】:

我正在尝试关注this blog 的帖子,为我的每个出版物自动生成.md 文件,以用于blogdown。帖子中的函数使用包 RefManageR 从 BibTeX 文件中读取条目,并为每个条目创建一个 .md 文件。

我的问题是我无法让RefManageR 正确读取特殊字符,即使我煞费苦心地使用 UTF-8 编码保存.bib 并在对ReadBib 的调用中指定编码。

例如:我使用 Zotero 生成我的.bib,方法是使用 UTF-8 编码将集合导出到 BibTeX。它在我的.bib 中为我提供了以下条目:

@article{senior_pantropical_2017,
         title = {A pantropical analysis of the impacts of forest 
                 degradation and conversion on local temperature},
         volume = {7},
         issn = {2045-7758},
         doi = {10.1002/ece3.3262},
         number = {19},
         journal = {Ecology and Evolution},
         author = {Senior, Rebecca A. and Hill, Jane K. and González del 
                   Pliego, Pamela and Goode, Laurel K. and Edwards, David P.},
         month = oct,
         year = {2017},
         pages = {7897--7908}
}

如您所见,其中一位作者的名字(González del Pliego)带有重音符号。我通过在 RStudio 中打开(字符显示正确)来检查编码,并确保我做了“使用编码保存”。无论我做什么,当我像这样将.bib 读入 R 时:

ReadBib('path/to/refs.bib', .Encoding = "UTF-8")

它总是这样显示:

[1] R. A. Senior, J. K. Hill, P. González del Pliego, et al. “A pantropical analysis of the impacts of forest degradation and conversion on local temperature”. In: _Ecology and Evolution_7.19 (Oct. 2017), pp. 7897-7908. ISSN: 2045-7758. DOI: 10.1002/ece3.3262.

为什么 á 显示为 á我尝试了各种包和函数(RefManageR::ReadBibbibtex::read.bibbib2df::bib2df)以及各种不同的指定和检查编码的方法。我无法手动排版字符(例如{\'a}),因为我的一些出版物有很多作者。不知道如何继续。

【问题讨论】:

  • 更新:现在我无法弄清楚这一点,所以我手动排版字符,尽管对于某些字符(例如 í )来说这仍然有点不确定

标签: r bibtex blogdown


【解决方案1】:

我使用bib2df::bib2df() 读取UTF-8 编码的bibtex 文件。

options(encoding="UTF-8")
bib_df <- bib2df("publications.bib")

它对我有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-28
    • 1970-01-01
    • 1970-01-01
    • 2020-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多