Reputation: 309
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
Upvotes: 1
Views: 282
Reputation: 1
=SPLIT(INDIRECT(CHAR(RANDBETWEEN(65,67))&ROW())&
"♥"&INDIRECT(CHAR(RANDBETWEEN(65,67))&ROW()),"♥")
Upvotes: 0
Reputation: 887158
We can do this with apply
t(apply(data, 1, function(x) sample(x, 2)))
Upvotes: 1