Tung
1
Say I have a dataframe that is:
y <- c(8,3,1,11,4,7)
I want to get the all possible (15 cases) random data with size 2. I know how to draw randomly for one of them:
sample(y, 2)
But how to get all of them? Because I need to do further data analysis.
FJCC
2
You can use the combn() function. I'll note that y is a vector, not a data frame.
combn(c(8,3,1,11,4,7), 2)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15]
[1,] 8 8 8 8 8 3 3 3 3 1 1 1 11 11 4
[2,] 3 1 11 4 7 1 11 4 7 11 4 7 4 7 7
1 Like
system
Closed
3
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.