0

I have a custom-made RV called X<-function(par) which returns a d-dimensional vector. Now I want to draw n samples and have them stored in a d,n-dimensional matrix. Is there a way to do this without using a loop?

Thank you!

  • 3
    It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Probably `replicate(n, X())` will work. For example `replicate(5, rnorm(3))` – MrFlick May 04 '22 at 14:25
  • Thank you, replicate already does the trick! – KennyfromSouthpark May 04 '22 at 14:53
  • Does this answer your question? [R reshape a vector into multiple columns](https://stackoverflow.com/questions/17752830/r-reshape-a-vector-into-multiple-columns) – Severin Pappadeux May 04 '22 at 20:25

0 Answers0