mercredi 19 juillet 2017

R - Sample random values from each row individually

pretty simple question in R, I don't have much of a Computer/Math background but it's a pretty useful tool and help would be greatly appreciated.

I have an "experiment" where 5 votes were collected for each sample. I'd like to randomly sample 4 values from each row randomly.

I tried Votes4<-sample(data,4,replace=F)

but instead of doing it for each row, it just randomly select 4 of the 5 columns and uses those for all rows, while I would like for R to repeat the process for each row.

Hope I'm making sense, thanks




Aucun commentaire:

Enregistrer un commentaire