vendredi 12 novembre 2021

Creating data.frame of multiple random samples from a vector in R?

I have the vector X and I would like to generate a data.frame of 6 integer samples of size 4. In other words, I would like to have a data.frame of 6 * 4 dimension. I tried the following the following but its throwing out lenght argument error.

set.seed(123)

X <- c(4,10,15,100,50,31,311,225,85,91)

S <- replicate(X, sample.int(n = 6, size = 4))



Aucun commentaire:

Enregistrer un commentaire