Re: [R] Permutations with replacement (final final final)

2006-08-21 Thread Jesse Albert Canchola
Hi Daniel,

Turns out, your code, however simple, is quite elegant for my needs 
(sometimes I overanalyze  :O).  Here is my last code to do what I need to 
do:

### begin R code 
# generate a matrix of ten thousand rows of 1-8 
z - t(matrix(rep(1:8,1),8,1))
library(Matrix)
# use the R sample function in a loop to sample each line with replacement
zcomb=Matrix()
for (i in 1:dim(z)[1]) {
z1 - t(matrix(sample(z,8,replace=TRUE)))
zcomb = rbind(zcomb,z1)
}
zcomb
### end R code #

Regards,
Jesse A. Canchola





Daniel Nordlund [EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
08/18/2006 05:16 PM

To
'Jesse Albert Canchola' [EMAIL PROTECTED], 'r-help' 
r-help@stat.math.ethz.ch
cc

Subject
Re: [R] Permutations with replacement






 -Original Message-
 From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED]
 On Behalf Of Jesse Albert Canchola
 Sent: Friday, August 18, 2006 1:02 PM
 To: r-help
 Subject: [R] Permutations with replacement
 
 Is there a simple function or process that will create 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,]123
 [2,]132
 [3,]312
 [4,]321
 [5,]231
 [6,]213
 ## end R code ##
 
 I'd like to include the with replacement possibilities such as
 
 1,1,3
 1,1,2
 2,3,3
 
Isn't what you want just sampling with replacement?

  x - c(1,2,3)
  sample(x,3,replace=TRUE)

Hope this is helpful,

Dan

Dan Nordlund
Bothell, WA  USA

__
R-help@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.




___

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@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.


Re: [R] Permutations with replacement

2006-08-20 Thread Jesse Albert Canchola
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




[EMAIL PROTECTED] 
Sent by: [EMAIL PROTECTED]
08/18/2006 01:33 PM

To
Jesse Albert Canchola [EMAIL PROTECTED], r-help 
r-help@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: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 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,]123
[2,]132
[3,]312
[4,]321
[5,]231
[6,]213
## 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@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@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@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] Permutations with replacement

2006-08-18 Thread Jesse Albert Canchola
Is there a simple function or process that will create 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,]123
[2,]132
[3,]312
[4,]321
[5,]231
[6,]213
## 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@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] Permutations with replacement

2006-08-18 Thread Jesse Albert Canchola
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,]123
[2,]132
[3,]312
[4,]321
[5,]231
[6,]213
## 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@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.


Re: [R] Permutations with replacement

2006-08-18 Thread davidr
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: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 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,]123
[2,]132
[3,]312
[4,]321
[5,]231
[6,]213
## 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@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@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.


Re: [R] Permutations with replacement

2006-08-18 Thread Daniel Nordlund
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 On Behalf Of Jesse Albert Canchola
 Sent: Friday, August 18, 2006 1:02 PM
 To: r-help
 Subject: [R] Permutations with replacement
 
 Is there a simple function or process that will create 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,]123
 [2,]132
 [3,]312
 [4,]321
 [5,]231
 [6,]213
 ## end R code ##
 
 I'd like to include the with replacement possibilities such as
 
 1,1,3
 1,1,2
 2,3,3
 
Isn't what you want just sampling with replacement?

  x - c(1,2,3)
  sample(x,3,replace=TRUE)

Hope this is helpful,

Dan

Dan Nordlund
Bothell, WA  USA

__
R-help@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.