[R] Permutations of variables in a dataframe
Serguei Kaniovski
Serguei.Kaniovski at wifo.ac.at
Mon Jan 14 14:27:13 CET 2008
Hallo All,
I would like to apply a function to all permutations of variables in a
dataframe (except the first). What is the best way to achieve this?
I produce the permutations using:
nvar <- ncol(dat) - 1
perms <- as.matrix( expand.grid(rep( list(1:0) , nvar ))[ , nvar:1] )
Thanks in advance
Serguei
Test-dataframe, comma-delimited:
code,wav,w,area,gdp,def,pop,coast,milspend,agr
aut,5,10,83.87,26.39,-1.29,8.07,0,0.72,1.81
bel,1,12,30.53,24.87,-0.28,10.29,0.07,1.29,1.09
bul,7,10,110.91,2.14,1.22,8.03,0.35,1.46,10.88
cyp,6,4,9.25,14.65,-3.26,0.7,0.65,2.11,3.2
cze,6,12,78.87,6.88,-4.44,10.26,0,2,3.19
dnk,2,7,43.09,32.75,2.05,5.34,7.31,1.53,1.98
est,6,4,45.23,5.15,0.82,1.38,3.79,1.58,3.91
fin,5,7,338.15,25.5,3.52,5.18,1.25,1.33,2.87
fra,1,29,547.03,23.99,-2.63,61.05,3.43,2.61,2.39
More information about the R-help
mailing list