[R] Permutations with replacement
Jesse Albert Canchola
jesse.canchola.b at bayer.com
Mon Aug 21 01:32:12 CEST 2006
Thanks, David. That worked fabulously!
Here is the R code for the hypercube test example:
########## begin R code ############
library(combinat)
x <- rep(3,3) # for partitions of 3 units into the three classes {1,2,3}
hcube(x, scale=1, transl=0)
########### end R code ############
For the larger one I want (i.e., 8^8), I will take a random sample of
10,000 from the 16,777,216 possibilities.
Regards,
Jesse Canchola
<davidr at rhotrading.com>
Sent by: r-help-bounces at stat.math.ethz.ch
08/18/2006 01:33 PM
To
"Jesse Albert Canchola" <jesse.canchola.b at bayer.com>, "r-help"
<r-help at stat.math.ethz.ch>
cc
Subject
Re: [R] Permutations with replacement
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
Canchola
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
1,1,3
1,1,2
2,3,3
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
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list