[R] Permutations with replacement

davidr at rhotrading.com davidr at rhotrading.com
Fri Aug 18 22:33:20 CEST 2006

If you also want 1,1,1 and so on, the number of these is n^n,
(n choices for each of n slots.)
In that case, you could use hcube from combinat.

David L. Reiner
Rho Trading Securities, LLC
Chicago  IL  60605

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Jesse Albert
Sent: Friday, August 18, 2006 3:26 PM
To: r-help
Subject: [R] Permutations with replacement

Is there a simple function or process that will create a matrix of 
permutations with replacement? 

I know that using the combinat package

###### begin R code ######
> library(combinat)
> m <- t(array(unlist(permn(3)), dim = c(3, 6)))

# we can get the permutations, for example 3!=6
# gives us

> m
     [,1] [,2] [,3]
[1,]    1    2    3
[2,]    1    3    2
[3,]    3    1    2
[4,]    3    2    1
[5,]    2    3    1
[6,]    2    1    3
###### end R code ##########

I'd like to include the "with replacement possibilities" such as 


and so on.  This will eventually be done on 8!=40,320 rather than the 
development version using 3! as above.

If no function exists (I've Googled on CRAN with no palpable luck), then

perhaps this is more of a bootstrap type problem. 

Thanks for your help in advance,
Jesse Canchola


The information contained in this e-mail is for the exclusive use of the
intended recipient(s) and may be confidential, proprietary, and/or
legally privileged.  Inadvertent disclosure of this message does not
constitute a waiver of any privilege.  If you receive this message in
error, please do not directly or indirectly use, print, copy, forward,
or disclose any part of this message.  Please also delete this e-mail
and all copies and notify the sender.  Thank you.

For alternate languages please go to http://bayerdisclaimer.bayerweb.com

R-help at stat.math.ethz.ch mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list