R:安装包的问题(与目录名中的空格有关?)

时间:2016-05-10 17:08:37

标签: r windows install.packages

我试图安装CausalImpact包并因为依赖于bsts而失败。

我试图安装bsts但没有成功,看看结果我看到我认为是对Boom的依赖失败了:

install.packages("bsts", lib="C:/R/win-library/3.3")

Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘bsts’
Do you want to attempt to install these from sources?
y/n: y
installing the source package ‘bsts’

trying URL 'https://cran.rstudio.com/src/contrib/bsts_0.6.3.tar.gz'
Content type 'application/x-gzip' length 148815 bytes (145 KB)
downloaded 145 KB

* installing *source* package 'bsts' ...
** package 'bsts' successfully unpacked and MD5 sums checked
** libs

*** arch - i386
c:/Rtools/mingw_32/bin/g++  -std=c++0x -I"C:/PROGRA~1/R/R-33~1.0/include" -DNDEBUG -I`C:/PROGRA~1/R/R-33~1.0/bin/Rscript -e "cat(system.file(package='Boom'))"`/include -DNO_BOOST_THREADS -DNO_BOOST_FILESYSTEM -DADD_ -DR_NO_REMAP -DRLANGUAGE   -I"C:/Users/Firstname Lastname/Documents/R/win-library/3.3/Boom/include" -I"C:/Users/Firstname Lastname/Documents/R/win-library/3.3/BH/include" -I"d:/Compiler/gcc-4.9.3/local330/include"     -O2 -Wall  -mtune=core2 -c aggregate_time_series.cc -o aggregate_time_series.o
g++.exe: error: Lastname/Documents/R/win-library/3.3/Boom/include: No such file or directory

我认为g ++会让人感到不安,因为R已将该库放在 C:Users / Firstname Lastname 的子文件夹中,并且它不喜欢我名字中的空格。

我尝试将R_LIBS_USER环境变量设置为C:/R/win-library/3.3以通过路径中的空格消除此问题,但没有成功 - 即使在完全重新启动计算机后,错误也会重复 - 它仍然会转到C:/ Users / Firstname Lastname / Documents / R / win-library / 3.3目录。

我在Windows 10上使用RStudio 0.99.896和R 3.3.0,如果这有任何区别

1 个答案:

答案 0 :(得分:0)

正如本related question中所述,如果您不一定需要最新版本的bsts,您仍然可以在Windows上安装0.6.2版,这样您就可以安装CausalImpact

install.packages("https://cran.r-project.org/bin/windows/contrib/3.2/bsts_0.6.2.zip", 
                  repos = NULL, type = "local")
library(devtools)
devtools::install_github("google/CausalImpact")

适用于Win 10,R 3.3.0