2

我正在尝试根据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。问题解决了。

4

2 回答 2

0

I had the same problem. Everything worked fine until the "hello world" of the C++ installation check. Then, I ran the suggested lines:

options(repos = c(getOption("repos"), rstan = "http://wiki.rstan-repo.googlecode.com/git/")) install.packages('rstan', type = 'source')

I had plenty of 404 errors. The last lines of the output were:

The downloaded source packages are in ‘C:\Users\U111499\AppData\Local\Temp\RtmpYfj24v\downloaded_packages’</p>

Then I went to the package tab of RStudio, clicked "Install Packages", selected "Install from: Package Archive File", then the "rstan_2.2.0.tar.gz" that I found under the path mentionned above. That finally seemed to do the trick. Good luck !

于 2014-05-06T09:39:57.387 回答
0

这对我有用:

install.packages("rstan", repos = "https://cran.r-project.org", dependencies = TRUE)

见这里:https ://github.com/stan-dev/rstan/issues/304

于 2021-02-14T01:59:06.137 回答