# [R] Help With Permutations

(Ted Harding) Ted.Harding at manchester.ac.uk
Mon Nov 24 17:43:33 CET 2008

```On 24-Nov-08 13:36:31, Mulazzani Fabio (Student Com06) wrote:
> I have a problem with permutations functions in R
> I just started using R so maybe it is an easy question
> I need to obtain all the 9.somthingExp 157 permutations that can be
> given from the number from 1 to 100
>
> I wrote the following commands:
>
>> library(gregmisc)
>>options(expressions=1e5)
>      cmat <- combinations(300,2)
>      dim(cmat) # 44850 by 2
>>permutations(n=100, r=100)
>
> Unfortunately at a certain point (after few minutes) I get the
> following Error:
>
> Error: cannot allocate vector of size 609.1 Mb
>
> What can I do?
> Thanks
> Fabio

The first thing to do is to decide how long you are willing to wait!

To an adequate approximation there are 10^158 of them.
Simply to obtain them all (at a rate of 10^10 per second, which is
faster than the CPU frequency of most desktop computers) would take
10^148 seconds, or slightly longer than 3*(10^140) years.

Current estimates of the age of the Universe are of the order of
1.5*(10^10) years, so the Universe will have to last about 2*(10^130)
times as long as it has already existed, before the task could
be finished.

So: why do you want to do this?

Best wishes,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 24-Nov-08                                       Time: 16:43:29
------------------------------ XFMail ------------------------------

```