I need to pick randomly 2 cells from a row (specific range/columns of the row).
Al Em Kev
1 1 2
3 2 3
2 2 1
3 3 3
output:
rand 1 rand 2
2 1
3 2
2 2
3 3
The results need to be unique: the same cell cannot be returned both times.
It would be quicker to do it in Google sheets right now, but an answer using R would be fine as well.
Thanks guys
我们可以通过apply
做到这一点
t(apply(data, 1, function(x) sample(x, 2)))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.