I'm using R. Let's say I have four numeric x1,x2,x3,x4 and each of them have length about 50 to 100. Then, I want to combine them and I use c(x1,x2,x3,x4). Is there any way that I can randonmly combine them. For example, c(x1,x3,x4,x2),c(x3,x1,x2,x4).
Put them in a list
, shuffle the order of the list
, and then unlist()
them into a single vector.
result = list(x1, x2, x3, x4)
result = result[sample(seq_along(result))]
result = unlist(result)
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.