jeudi 25 février 2021

sample from more than one column

I have a df of numeric character values which looks like this -

set.seed(89)
a <- sample(1:30, 25, replace = T) 
b <- sample(1:30, 25, replace = T) 
d <- cbind(a,b)

I now want to sample into two new columns V1 and V2 for the length as d, from those distinct character values, with replacement, but I keep getting replicated columns (V1 = V2).

This feels like I am missing something obvious ?




Aucun commentaire:

Enregistrer un commentaire