I installed rstan from the “source”. I made sure rtools40 is up to date and created the .Renviron file in Documents. Made sure there is no .Rprofile file. But I am still getting an error when running the example model.
> library(rstan)
Loading required package: StanHeaders
Loading required package: ggplot2
Need help getting started? Try the R Graphics Cookbook: https://r-graphics.org
rstan (Version 2.21.2, GitRev: 2e1f913d3ca3)
For execution on a local, multicore CPU with excess RAM we recommend calling
options(mc.cores = parallel::detectCores()).
To avoid recompilation of unchanged Stan programs, we recommend calling
rstan_options(auto_write = TRUE)
Do not specify '-march=native' in 'LOCAL_CPPFLAGS' or a Makevars file
> example(stan_model, package = "rstan", run.dontrun = TRUE)
Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
clone_impl: ^C:/Users/chascott/Documents/R/win-library/4.1/BH/include/boost/exception/exception.hpp:472:9: error: expected declaration before '}' token } ^make: *** [C:/PROGRA~1/R/R-41~1.1/etc/x64/Makeconf:245: file3c4470556947.o] Error 1
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
'C:/rtools40/usr/mingw_/bin/g++' not found
readLines(“~/.Rprofile”)
Error in file(con, “r”) : cannot open the connection
In addition: Warning message:
In file(con, “r”) :
cannot open file ‘C:/Users/cs/Documents/.Rprofile’: No such file or directory
# Compile packages using all cores
Sys.setenv(MAKEFLAGS = paste0("-j",parallel::detectCores()))
install.packages(c("StanHeaders","rstan"),type="source")