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

**URL:** <https://discourse.mc-stan.org/t/how-to-pass-a-row-or-a-column-of-numbers/22946>\
**Category:** General\
**Created:** [June 9, 2021, 8:56pm UTC](https://discourse.mc-stan.org/t/how-to-pass-a-row-or-a-column-of-numbers/22946 "2021-06-09T20:56:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sonicking](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@sonicking](https://discourse.mc-stan.org/u/sonicking)\
**Post date:** [June 9, 2021, 8:56pm UTC](https://discourse.mc-stan.org/t/how-to-pass-a-row-or-a-column-of-numbers/22946/1 "2021-06-09T20:56:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![caesoma](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/caesoma/32/19767_2.png) [@caesoma](https://discourse.mc-stan.org/u/caesoma)\
**Post date:** [June 13, 2021, 4:00pm UTC](https://discourse.mc-stan.org/t/how-to-pass-a-row-or-a-column-of-numbers/22946/2 "2021-06-13T16:00:31Z")

</div>

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.
