How to pass a row (or a column) of numbers

Ok, this may seem like a silly question but I am stuck.

I got the following error message:

Error in new_CppObject_xp(fields$.module, fields$.pointer, …) :
Exception: mismatch in number dimensions declared and found in context; processing stage=data initialization; variable name=Xk_new; dims declared=(4); dims found=(4,1)

In R, my Xk_new variable is created simply as:
Xk_new <- t(prod_attr[6,2:5])
where prod_attr is a data.frame.

This is how I declare Xk_new in the stan code:
real Xk_new[4];

I also tried vector, but it also failed. Please help! Thank you.

Seems like the problem is not in the Stan code (necessarily), but the R object, which has dimensions (4,1) when Stan is expecting (4). That’s evident from the message, but more precisely – and I am not an R user – but it seems like your object looks like [[a,b,c,d]], and Stan expects [a,b,c,d]. Alternatively you could use matrix[4,1] Xk_new, but if the second dimension is always one a vector is probably a better option.