带有 R 包 Repmis 的重音字母

Accented letters with R package Repmis

我正在使用 repmis 来处理我报告中的引用,但是当引用包含重音字符时它不会编译 - 在这种情况下引用 nlme 包。

有解决办法吗?

我尝试将 options(encoding = "UTF-8") 添加到我的 .RProfile,但这没有帮助。我的解决方法是将引用复制到另一个 bib 文件并使用 Window 字符映射中的符号。虽然这有效,但这不是我要找的修复方法。

谢谢。

错误信息:

pandoc-citeproc: Cannot decode byte '\xe9': Data.Text.Internal.Encoding.decodeUtf8: Invalid UTF-8 stream Error running filter pandoc-citeproc: Filter returned error status 1 Error: pandoc document conversion failed with error 83 Execution halted

示例.Rmd:

---
title: "Untitled"
author: "Paul Stevenson"
date: "21 January 2019"
output: html_document
bibliography:
  - packages.bib
---

```{r}
library(repmis)
LoadandCite(pkgs = c("nlme"),
            file = "packages.bib")

```

Reference [@R-nlme]

书目条目:

@Manual{R-nlme,
  title = {nlme: Linear and Nonlinear Mixed Effects Models},
  author = {José Pinheiro and Douglas Bates and {R-core}},
  year = {2018},
  note = {R package version 3.1-137},
  url = {https://CRAN.R-project.org/package=nlme},
}

sessionInfo():

R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252   
[3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.5.2  htmltools_0.3.6 tools_3.5.2     yaml_2.2.0     
 [5] Rcpp_1.0.0      rmarkdown_1.11  knitr_1.21      xfun_0.4       
 [9] digest_0.6.18   evaluate_0.12  

通过打开 .bib 并使用 write.table(fileEncoding = "UTF-8") 保存,找到了更顺畅的解决方法。请参阅下面的 recoder 函数:

---
title: "Untitled"
author: "Paul Stevenson"
date: "21 January 2019"
output: html_document
bibliography:
  - packages.bib
---

```{r}
recoder <- function(x) {
  dat <- read.delim(file = x, header = F, stringsAsFactors = F, quote = "")
  write.table(dat, file = x, row.names = F, quote = F, col.names = F, fileEncoding = "UTF-8")
}

library(repmis)
library(nlme)
LoadandCite(pkgs = c("nlme", "biometrics"), file = "packages.bib")
recoder("packages.bib")

```

Reference [@R-nlme]