Re: [R] Simple permutation question

2014-06-27 Thread David Reiner
Subject: Re: [R] Simple permutation question For your 2nd question (which also answers your first question) I use the permn function in the combinat package, this function is nice that in addition to generating all the permutations it will also, optionally, run a function on each permutation for you: t

Re: [R] Simple permutation question

2014-06-26 Thread Robert Latest
On Wed, 25 Jun 2014 14:16:08 -0700 (PDT) Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: The brokenness of your perm.broken function arises from the attempted use of sapply to bind matrices together, which is not something sapply does. perm.fixed - function( x ) { if ( length( x ) == 1 )

Re: [R] Simple permutation question

2014-06-26 Thread Greg Snow
For your 2nd question (which also answers your first question) I use the permn function in the combinat package, this function is nice that in addition to generating all the permutations it will also, optionally, run a function on each permutation for you: t(simplify2array( permn( c(A,B,C) ) ))

[R] Simple permutation question

2014-06-25 Thread Robert Latest
So my company has hired a few young McKinsey guys from overseas for a couple of weeks to help us with a production line optimization. They probably charge what I make in a year, but that's OK because I just never have the time to really dive into one particular time, and I have to hand it to the

Re: [R] Simple permutation question

2014-06-25 Thread Cade, Brian
It is called sample(,replace=F), where the default argument is sampling without replacement. Try x - c(A,B,C,D,E) sample(x) Brian Brian S. Cade, PhD U. S. Geological Survey Fort Collins Science Center 2150 Centre Ave., Bldg. C Fort Collins, CO 80526-8818 email: ca...@usgs.gov

Re: [R] Simple permutation question

2014-06-25 Thread Ted Harding
I think Robert wants deterministic permutations. In the e1071 package -- load with library(e1071) -- there is a function permutations(): Description: Returns a matrix containing all permutations of the integers '1:n' (one permutation per row). Usage: permutations(n) Arguments: n:

Re: [R] Simple permutation question

2014-06-25 Thread David L Carlson
Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Cade, Brian Sent: Wednesday, June 25, 2014 3:39 PM To: Robert Latest Cc: r-help@r-project.org Subject: Re: [R] Simple permutation question It is called sample(,replace=F), where the default argument

Re: [R] Simple permutation question

2014-06-25 Thread Bert Gunter
and further... See ?Recall for how to do recursion in R. However, it is my understanding that recursion is not that efficient in R. A chain of function environments must be created, and this does not scale well. (Comments from real experts welcome here). Cheers, Bert Bert Gunter Genentech

Re: [R] Simple permutation question

2014-06-25 Thread David L Carlson
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David L Carlson Sent: Wednesday, June 25, 2014 4:02 PM To: Cade, Brian; Robert Latest Cc: r-help@r-project.org Subject: Re: [R] Simple permutation question Assuming you want all

Re: [R] Simple permutation question

2014-06-25 Thread Jeff Newmiller
The brokenness of your perm.broken function arises from the attempted use of sapply to bind matrices together, which is not something sapply does. perm.fixed - function( x ) { if ( length( x ) == 1 ) return( matrix( x, nrow=1 ) ) lst - lapply( seq_along( x ) , function( i ) {

Re: [R] Simple permutation question

2014-06-25 Thread Jeff Newmiller
sorry... editing on the fly... try: perm.fixed - function( x ) { if ( length( x ) == 1 ) return( matrix( x, nrow=1 ) ) lst - lapply( seq_along( x ) , function( i ) { cbind( x[ i ], perm.fixed( x[ -i ] ) ) } ) do.call( rbind,