It's the first time I post here. I usually search for alternatives when I face bugs (or errors) but, since I'm about to go further and deeper in R, so I would be pleased to understand what's happening.

I made a simple example to reproduce the error:

[Simple R code](https://i.stack.imgur.com/jLSRk.png)

[Execution](https://i.stack.imgur.com/IKDvD.png)

So, it appears that, "manually", sapply(a,replicate,b) does work. However, that expression inside a function returns an error.
I searched about 1 hour on the web but I haven't found anything alike.

I thank you for your time,