RStan error when try to fit data

I’m a beginner and was trying to fit use Rstan to fit some data following this project on Github: GitHub - dsmaynard/endpoints: Data and code for "Predicting coexistence in experimental ecological communities"

When I tried to use fit_stan to analyze the data, an error similar to Error in model fit: C++14 standard requested but CXX14 is not defined · Issue #569 · stan-dev/rstan · GitHub came out and saying CXX14 is not defined, I tried the suggestions and created the Makevars file. However now when I want to use fit_stan, the error become like this:

stan_results ← fit_stan(dt, stan_file = “Stan_file.stan”, chains = 2, cores = 2, iter = 15000, warmup = 7500, thin = 15)
[1] “fitting all endpoints”
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! sh: C:/Program: No such file or directory
make: *** [C:/PROGRA~1/R/R-36~1.1/etc/x64/Makeconf:215: file26104b4d24a6.o] Error 127
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘C:/PROGRA~1/R/R-36~1.1/bin/x64/R CMD SHLIB file26104b4d24a6.cpp 2> file26104b4d24a6.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection

Hope someone can see this and help me. Thanks a lot in advance!

You are going to need to put paths with spaces inside quotes.

@bgoodri It’s soooo awkward. I don’t know what does that mean. It seems like I made a stupid mistake but I’m not sure what to do. Do you mean I need to put spaces in paths when configure C++ toolchain? Thank you so much for your help!

In ~/.R/Makevars.win , I guess you have something like

CXX14 = C:/Program Files/...

so change it to

CXX14 = "C:/Program Files/..."

@bgoodri I tried to create the Makevars file using following code:

dotR ← file.path(Sys.getenv(“HOME”), “.R”)
if (!file.exists(dotR)) dir.create(dotR)
M ← file.path(dotR, “Makevars.win”)
if (!file.exists(M)) file.create(M)
cat(“\nCXX14FLAGS=-O3 -march=native”,

  • "CXX14 = g++ -m$(WIN) -std=c++1y",
    
  • "CXX11FLAGS=-O3 -march=native",
    
  • file = M, sep = "\n", append = TRUE)
    

But it still doesn’t work. I changed the ‘g++’ after CXX14 into ‘C:/Program Files…/g++.exe’ but it’s still not working. I went to the folder mingw_64 and could not find a file named ‘g++.exe’ there. Do you know where I can get that? Thanks

It is in C:/Program Files/.../mingw_64/bin

Oh it’s working now! How silly I was lol! Thank you so much!!!