Is there any implementation of integer partitioning in R?
For example for input 4 I would like to get 5 vectors:
4
3 , 1
2 , 2
2 , 1 , 1
1 , 1 , 1 , 1
There are implementations in Python, Erlang, Java, C, Perl, but I can't find anything in R.
Is there any implementation of integer partitioning in R?
For example for input 4 I would like to get 5 vectors:
4
3 , 1
2 , 2
2 , 1 , 1
1 , 1 , 1 , 1
There are implementations in Python, Erlang, Java, C, Perl, but I can't find anything in R.
Use the "partitions" package:
install.packages("partitions")
library(partitions)
parts(4)
#
# [1,] 4 3 2 2 1
# [2,] 0 1 2 1 1
# [3,] 0 0 0 1 1
# [4,] 0 0 0 0 1