• R语言软件
  • 建立 package 出现 Error in c + +11 : 二进列运算符中有非数值参数

问题描述

尝试着建立 R package,笔者在 Mac 里一次成功,但 Windows pc 环境则不行。已安装最新 Rtools,RStudio 和 R 也是最新版。笔者很疑惑,path, 函数名,变量名都没有出现中文。
主要步骤参考了论坛里这篇《极简 R 包建立方法》。运行到build()时出现错误:

** R
** byte-compile and prepare package for lazy loading
Error in c + +11 : 二进列运算符中有非数值参数
Error : unable to load R code in package 'ECON6999'
ERROR: lazy loading failed for package 'ECON6999'
removing 'C:/Users/admin/AppData/Local/Temp/Rtmpo56uKD/Rinst2e844d454999/ECON6999'
In R CMD INSTALL


ERROR: package installation failed
Error in processx::run(bin, args = real_cmdargs, stdout_line_callback = real_callback(stdout), :
System command error

我的系统环境

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=Chinese (Simplified)China.936 LC_CTYPE=Chinese (Simplified)China.936

[3] LC_MONETARY=Chinese (Simplified)China.936 LC_NUMERIC=C

[5] LC_TIME=Chinese (Simplified)
China.936

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

other attached packages:
[1] usethis_1.4.0 devtools_2.0.1 ggplot2_3.1.0

loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 pillar_1.3.1 compiler_3.5.2 plyr_1.8.4

[5] prettyunits_1.0.2 remotes_2.0.2 tools_3.5.2 testthat_2.0.1

[9] digest_0.6.18 pkgbuild_1.0.2 pkgload_1.0.2 lattice_0.20-38

[13] memoise_1.1.0 tibble_2.0.1 gtable_0.2.0 pkgconfig_2.0.2

[17] rlang_0.3.1 Matrix_1.2-15 cli_1.0.1 rstudioapi_0.9.0

[21] commonmark_1.7 yaml_2.2.0 xml2_1.2.0 stringr_1.4.0

[25] roxygen2_6.1.1 withr_2.1.2 desc_1.2.0 fs_1.2.6

[29] rprojroot_1.3-2 grid_3.5.2 glue_1.3.0 R6_2.3.0

[33] processx_3.2.1 sessioninfo_1.1.1 purrr_0.3.0 callr_3.1.1

[37] magrittr_1.5 scales_1.0.0 backports_1.1.3 ps_1.3.0

[41] assertthat_0.2.0 colorspace_1.4-0 stringi_1.2.4 lazyeval_0.2.1

[45] munsell_0.5.0 RcppEigen_0.3.3.5.0 crayon_1.3.4

补充说明

可能和本问题无关的问题。我开始用的是 RStudio 里的 Build -> clean and rebuild,和之前问题一样,但出现的提示信息是乱码。

** R
** byte-compile and prepare package for lazy loading
Error in c + +11 : ���������������з���ֵ����
Error : unable to load R code in package 'ECON6999'
ERROR: lazy loading failed for package 'ECON6999'
removing 'C:/Users/admin/Documents/R/win-library/3.5/ECON6999'
In R CMD INSTALL

Exited with status 1.