Hi Diana,
Yes, this seems to be a little bug in the setparts function. The
following is a modified version which should work for any x > 0.
You'll see I've just changed a couple of lines...
setparts2 <- function (x)
{
if (length(x) == 1) {
if (x < 1)
stop("if single value, x
Hi Diane,
Does this do what you want ?
listParts <- function(n) {
# Generates a list of lists representing the partitions
# of an integer n
require(partitions)
x <- 1:n
apply(setparts(n), 2, function(pp) tapply(x, pp, function(xx) list(xx)))
}
Michael
On 12 November 2010 21:15, Diana Tich
Hi Diana,
Have a look at the setparts function in the partitions package.
Michael
On 12 November 2010 20:03, Diana wrote:
>
> Hi
>
> I am new on this forum. I am searching for a function in R which provides
> all partitions of a set, say for the set
> {1,2,3}
> you get
> {{1,2,3}}
> {1,{2,3}}
>
Hi
I am new on this forum. I am searching for a function in R which provides
all partitions of a set, say for the set
{1,2,3}
you get
{{1,2,3}}
{1,{2,3}}
{2,{1,3}}
{3,{1,2}}
{{1},{2},{3}}
. The number of partitions of a set is given by Bellsche`s number. The
number of possibilities of length (thi
4 matches
Mail list logo