我正在尝试根据https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started安装 RStan
我使用了 Windows 7、RStudio 0.98.501 和 R x64 3.0.2
我成功安装了包 inline 和 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。问题解决了。