# Possible to pass matrices of 0 rows to rstan?

**URL:** <https://discourse.mc-stan.org/t/possible-to-pass-matrices-of-0-rows-to-rstan/1573>\
**Category:** Modeling\
**Created:** [August 15, 2017, 9:34am UTC](https://discourse.mc-stan.org/t/possible-to-pass-matrices-of-0-rows-to-rstan/1573 "2017-08-15T09:34:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charles\_Driver](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/charles_driver/32/6524_2.png) [@Charles\_Driver](https://discourse.mc-stan.org/u/Charles_Driver)\
**Post date:** [August 15, 2017, 9:34am UTC](https://discourse.mc-stan.org/t/possible-to-pass-matrices-of-0-rows-to-rstan/1573/1 "2017-08-15T09:34:02Z")

</div>

Although stan lets me declare a matrix[0,2] data object, I can’t seem to pass such an object to rstan. Is there some trick, or am I just asking too much? :)

---

<div class="post-metadata">

**Author:** ![Charles\_Driver](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/charles_driver/32/6524_2.png) [@Charles\_Driver](https://discourse.mc-stan.org/u/Charles_Driver)\
**Post date:** [August 15, 2017, 9:45am UTC](https://discourse.mc-stan.org/t/possible-to-pass-matrices-of-0-rows-to-rstan/1573/2 "2017-08-15T09:45:27Z")

</div>

For some reason, when conditions in R caused the matrix to have 0 rows, it also changed from numeric to logical entries. Forcing it back to numeric with matrix(as.numeric(myobject),ncol=2) resolved the problem of passing data to stan.

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [August 15, 2017, 7:41pm UTC](https://discourse.mc-stan.org/t/possible-to-pass-matrices-of-0-rows-to-rstan/1573/3 "2017-08-15T19:41:25Z")

</div>

Thanks for writing back with the solution.
