[R] Permutations of variables in a dataframe

Henrique Dallazuanna wwwhsd at gmail.com
Mon Jan 14 16:13:08 CET 2008


Is this you want?

apply(apply(perms, 1, as.logical), 2, function(x)df[x])



On 14/01/2008, Serguei Kaniovski <Serguei.Kaniovski at wifo.ac.at> wrote:
> Henrique, I know I have to use "apply", but how do I select the columns of
> the dataframe using the permutation vectors produced by
>
> nvar <- ncol(dat) - 1
> perms <- as.matrix( expand.grid(rep( list(1:0) , nvar ))[ , nvar:1] )
>
> Serguei
>
>


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O




More information about the R-help mailing list