我正在尝试根据 https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started 安装 RStan
我使用的是 Windows 7、RStudio 0.98.501 和 R x64 3.0.2
我成功地安装了内联包和 Rcpp。
C++测试结果如下:
> src <- '
+ std::vector<std::string> s;
+ s.push_back("hello");
+ s.push_back("world");
+ return Rcpp::wrap(s);
+ '
> hellofun <- cxxfunction(body = src, includes = '', plugin = 'Rcpp', verbose = FALSE)
cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-30~1.2/etc/x64/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-30~1.2/etc/x64/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
> cat(hellofun(), '\n')
hello world
我认为“hello world”意味着我正确安装了 C++。
然后我输入以下代码:
> Sys.setenv(R_MAKEVARS_USER = "foobar")
> options(repos = c(getOption("repos"), rstan = "http://wiki.rstan-repo.googlecode.com/git/"))
> install.packages('rstan', type = 'source')
Warning in install.packages :
cannot open: HTTP status was '404 Not Found'
Warning in install.packages :
cannot open: HTTP status was '404 Not Found'
Warning in install.packages :
unable to access index for repository http://wiki.rstan-repo.googlecode.com/git/bin/windows/contrib/3.0
trying URL 'http://wiki.rstan-repo.googlecode.com/git/src/contrib/rstan_2.2.0.tar.gz'
Content type 'application/x-gzip' length 4515994 bytes (4.3 Mb)
opened URL
downloaded 4.3 Mb
ERROR: failed to lock directory 'C:/Program Files/R/R-3.0.2/library' for modifying
Try removing 'C:/Program Files/R/R-3.0.2/library/00LOCK-rstan'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-30~1.2/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.0.2\library" C:\Users \BYNBUT~1\AppData\Local\Temp\Rtmp4WmSTV/downloaded_packages/rstan_2.2.0.tar.gz' had status 3
Warning in install.packages :
installation of package ‘rstan’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\byny\AppData\Local\Temp\Rtmp4WmSTV\downloaded_packages’
然后,
> library(rstan)
Error in library(rstan) : there is no package called ‘rstan’
RStan 安装失败。
我不知道如何解决这个问题。
更新:我卸载了 R 的所有版本并安装了最新版本的 64 位 R。然后我再次安装了 RStan。问题解决了。
最佳答案
我遇到了同样的问题。一切正常,直到 C++ 安装检查的“hello world”。然后,我运行了建议的行:
选项(repos = c(getOption(“repos”),rstan =“http://wiki.rstan-repo.googlecode.com/git/”)) install.packages('rstan', type = 'source')
我有很多 404 错误。输出的最后几行是:
下载的源码包在 ‘C:\Users\U111499\AppData\Local\Temp\RtmpYfj24v\downloaded_packages’
然后我转到 RStudio 的包选项卡,单击“安装包”,选择“安装自:包存档文件”,然后是我在上述路径下找到的“rstan_2.2.0.tar.gz”。这似乎终于奏效了。祝你好运!
关于c++ - 错误 : failed to lock directory 'C:/Program Files/R/R-3.0.2/library' for modifying when installing RStan in Rstudio in Windows 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23483303/