dimanche 17 octobre 2021

How to generate random vectors and store as multiple objects in R?

I want to generate multiple random vectors:

a <- rnorm(10)
b <- rnorm(10)
c <- rnorm(10)

Is there a way to do this more concisely? For example, doing the following assigns the same numbers to a, b, c, which is something I don't want.

a <- b <- c <- rnorm(10)

Another way is to use a for loop, but is there a more concise way?




Aucun commentaire:

Enregistrer un commentaire