I'm trying to get all the combinations of a vector. I have
x <- c(1,2,3)
I need to get all the possible combinations without specifying the number of elements needed and without taking into account the order (the solution {2,3,1}
is the same as {1,2,3}
). For example, the result would be:
{}
{3}
{2}
{2,3}
{1}
{1,3}
{1,2}
{1,2,3}
An approximation would be to make the following table:
I am sure that there must be some function that performs this task instead of creating the table and forming the solutions from it, since it is not very tedious.