Hi Bernardo,
We don't support all of R's operations in the run function of a nimbleFunction because of limitations on what we can compile from R to C++.
In particular you can't use minus in indexing (I'm doing a bit of work right now to make that more clear in our documentation and error-trapping).
Also, you can't use a vector as the second argument to `rep`.
I haven't fully checked, but I think if you rework your `getClustersN` function to do the equivalent operations in a more 'manual' way, that will hopefully resolve things. Note that since the `run` code will be compiled to C++, you can use loops there without worrying that the loop will be slow.
Feel free to iterate here if that doesn't clear things up or getting things working for you.
-chris