The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Examples of generating combinations

Randy Lai

2020-01-08

  1. combinations: without replacement: distinct items
I <- iterpc(5, 2)
getall(I)
##       [,1] [,2]
##  [1,]    1    2
##  [2,]    1    3
##  [3,]    1    4
##  [4,]    1    5
##  [5,]    2    3
##  [6,]    2    4
##  [7,]    2    5
##  [8,]    3    4
##  [9,]    3    5
## [10,]    4    5
  1. combinations: with replacement: distinct items
I <- iterpc(5, 2, replace = TRUE)
getall(I)
##       [,1] [,2]
##  [1,]    1    1
##  [2,]    1    2
##  [3,]    1    3
##  [4,]    1    4
##  [5,]    1    5
##  [6,]    2    2
##  [7,]    2    3
##  [8,]    2    4
##  [9,]    2    5
## [10,]    3    3
## [11,]    3    4
## [12,]    3    5
## [13,]    4    4
## [14,]    4    5
## [15,]    5    5
  1. combinations: without replacement: non distinct items
x <- c("a", "a", "b", "c")
I <- iterpc(table(x), 2)
# or I <- iterpc(c(2,1,1), 2, label=c("a", "b", "c"))
getall(I)
##      [,1] [,2]
## [1,]    1    1
## [2,]    1    2
## [3,]    1    3
## [4,]    2    3
  1. combinations: with replacement: non distinct items
x <- c("a", "a", "b", "c")
I <- iterpc(table(x), 2, replace = TRUE)
# or I = iterpc(c(2,1,1), 2, label=c("a", "b", "c"), replace=TRUE)
getall(I)
##      [,1] [,2]
## [1,]    1    1
## [2,]    1    2
## [3,]    1    3
## [4,]    2    2
## [5,]    2    3
## [6,]    3    3

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.