mardi 4 août 2020

R: How can I store various random numbers generated by a loop in a matrix?

I want to generate 10 times 20 random numbers between 1 and 100. The final matrix therefore should include 200 numbers in total. This my way, how I tried to solve it:

x <- 10
N <- 20
A <- matrix()

for (i in 1:x) {
  
  A[i] <- sample(1:100, N, FALSE)
  
}

A

It results, that something seems to be wrong with A.




Aucun commentaire:

Enregistrer un commentaire