Error: Invalid Connection, Warning: 'C:/R/rtools40/usr/mingw_/bin/g++'

I received these errors when I tried fitting a model with Rstan. I an very new to R and rstan, so any help is appreciated! Happy to provide additional output as needed!

Error in cor(fit@fit$daily$ER_mean, fit@fit$daily$K600_daily_mean, use = “na.or.complete”) :
supply both ‘x’ and ‘y’ or a matrix-like ‘x’

In addition: Warning message:
In metab_fun(specs = specs, data = data, data_daily = data_daily, :
Modeling failed
‘C:/R/rtools40/usr/mingw_/bin/g++’ not found Errors:
invalid connection

Rstan can be somewhat frustrating to get running. Unfortunately, this doesn’t let us debug the issue very well. If I understand you correctly, you were able to fit a model, but you only get errors after running the cor(...) command above? Could you share the full R code and Stan code you use?

Or are you unable to even fit the model without issues? If so, did you follow RStan Getting Started · stan-dev/rstan Wiki · GitHub ? If yes, did you have some issues following it? If no, could you try following the advice?

Best of luck!