2.19.2 error variable does not exist mac

I just upgraded to 2.19.2 on my Mac - did it in RStudio. Using R 3.6.1.
Now stan code that used to work fine is getting an error variable does not exist. Like this:
Error in new_CppObject_xp(fields$.module, fields$.pointer, …) :
Exception: variable does not exist; processing stage=data initialization; variable name=N; base type=int (in ‘model184272c0d7b22_CVVessDel0823’ at line 2)

failed to create the sampler; sampling not done

Line 2 and above are:
data {
int<lower=0> N; //# rows

I define N in the R workspace using:
N <- as.integer(nrow(y))

I just added the as.integer part when I started getting this error message but it didn’t help

I just happen to be searching about this and saw your posting.

My co-workers who use Windows 10, and the latest versions of R, RStudio, RTools, have the same issue.

I did the same on my Mac, latest and greatest released versions, and have the same issue.

I can pass in a list of data and that works.

– Stephen

How do you pass in a list of data? Stan documentation is sparse on that. I tried to pass an integer vector by first doing this in R, with results shown:

nu = (array(integer(1), 2))
nu[1] = N;
nu[2] = U;
is.integer(nu)
[1] TRUE
dim(nu)
[1] 2
nu
[1] 86 8

Then I put this in the data block of Stan:
data {
//int<lower=0> N; //# rows
//int<lower=0> U; //# columns
int nu[2];

Then I got the same error:
Error in new_CppObject_xp(fields$.module, fields$.pointer, …) :
Exception: variable does not exist; processing stage=data initialization; variable name=nu; base type=int (in ‘model184277056b0be_CVVessDel0823nu’ at line 4)

failed to create the sampler; sampling not done

I’m not at my computer at the moment, but if you go to the help ?stan, there is a section on passing data to stan.

Basically create something like data <- list(y=y, x=x, etc=etc), then when calling stan use the data input.

Ok - found it in a post called Passing data as a list vs character vector by jjvalletta

You make a list in R then pass it when you run Stan as in:

fit <- stan(model_code=stan_code, data=df) 

Then the stan code doesn’t have to change at all.

After all this, I’m hoping that 2.19.2 is worth the trouble. And thanks for pointing me in the right direction.

Solved.