[R] R loop help
casperyc
casperyc at hotmail.co.uk
Wed Apr 7 00:35:34 CEST 2010
Hi there,
That's exactly what I want.
I have checked ?combn out,
but I could get the following,
suppose that I want ALL possible combinations of them,
as this
==================================
apply(
combn(paste('x', 1:4, sep =""), 2), 2,
function(v) get(v[1])*get(v[2])
),
apply(
combn(paste('x', 1:4, sep =""), 3), 2,
function(v) get(v[1])*get(v[2])*get(v[3])
),
apply(
combn(paste('x', 1:4, sep =""), 4), 2,
function(v) get(v[1])*get(v[2])*get(v[3])*get(v[4])
)
)
==================================
combn(paste('x', 1:4, sep =""), 2)
lists all the '2' factor combinations,
combn(paste('x', 1:4, sep =""),3)
lists all the '3' factor combinations,
ect,
I have tried to use
combn(paste('x', 1:4, sep =""), c(2,3,4))
to get all possible combinations,
but didnt work
how should I proceed?
Thanks!
casper
--
View this message in context: http://n4.nabble.com/R-loop-help-tp1692945p1753626.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list