Dear R-Users,
I need a matrix containing line by line all possible permutations with
length 'i' of the integers 1:N, given the restriction that the
integers in each row have to be in ascending order.
For example: N = 5, length i = 3, should result in a matrix like this:
1 2 3
1 2 4
1 2 5
help.search('combination')
?combn
combn(1:5,3)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]111111222 3
[2,]222334334 4
[3,]345455455 5
On 1/30/07, michel
Hi
library(gtools)
combinations(5,3)
[,1] [,2] [,3]
[1,]123
[2,]124
[3,]125
[4,]134
[5,]135
[6,]145
[7,]234
[8,]235
[9,]245
[10,]345
On 30 Jan 2007, at