You can easily write your own function to do this:
vector r_style_subset(vector x, vector cond) {
vector[sum(cond)] y;
int pos;
pos <- 1;
for (i in 1:rows(x)) {
if (cond[i]) {
y[pos] <- x[i];
pos <- pos + 1;
}
}
return y;
}
It should really test that the entries in cond are 0 or 1,
and that x and cond have the same number of rows.
But I'm guessing you really want it to work for all possible
container shapes and you want us to extend all of our comparison
operators to allow R-like idioms such as y[y > 10].
It's not that hard to do, but will require a different syntax
because we don't have a proper bool type. Nobody has any time
soon to do it, though.
- Bob
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
stan-users+...@googlegroups.com.
> To post to this group, send email to
stan-...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.