0

I am having troubles installing RStan. Anytime I try, my code returns False.

install.packages("rstan")
pkgbuild::has_build_tools(debug = TRUE)
Scanning R CMD config CC...
cc_path:  
'' does not exist
Scanning path...
Scanning registry...
WARNING: Rtools is required to build R packages, but is not currently installed.

Please download and install Rtools custom from https://cran.r-project.org/bin/windows/Rtools/.
[1] FALSE

Once it gives me the WARNING message, it asks me if I want to install Rtools. I click "Yes" and then it returns [1] FALSE. And Rtools is not installed. Could someone advise please?

Operating System: Windows 10

Interface Version: RStan.

Compiler/Toolkit: g++

Andrew
  • 195
  • 2
  • 12
  • You say you're having touble installing `Rtools`, but your output implies you're trying to install `rstan`... – Limey Jun 20 '20 at 13:49
  • Thank you for pointing that out. I've edited my question for clarity. I am trying to install RStan but it says I must install Rtools first. However, it returns FALSE when I try to install Rtools. – Andrew Jun 20 '20 at 13:52
  • Ok. Thanks. But your code snippet still references `rstan`. Perhaps you can restart R/Rstudio, then try `install.packages("Rtools")`... Same error message? – Limey Jun 20 '20 at 13:56

1 Answers1

1

You'll need to install RTools on Windows (please check your R version and choose correct RTools version).

However, without RTools, probably the easiest way is to just run:

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

(Binary version shouldn't require RTools nor any compiler.)

  • Wouldn't a c++ compiler (i.e. from Rtools) still be needed to compile the custom stan models ? – user20650 Jun 20 '20 at 14:42
  • @user20650 Thanks, good point, that's true. But Andrew can try to install RTools separately (outside RStudio) from the [link](https://cran.r-project.org/bin/windows/Rtools/history.html) above, and if that doesn't work I hope it's possible to configure rstan to use available g++ compiler in [makevars](https://stackoverflow.com/questions/43597632/understanding-the-contents-of-the-makevars-file-in-r-macros-variables-r-ma) (probably, haven't tried or needed). –  Jun 20 '20 at 16:06
  • 1
    I agree Petr, if they install the rtools exe manually and follow the instructions at the link you provide to add it to their path they shouldn't have a problem. – user20650 Jun 20 '20 at 16:47