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.

______________________________________________
R-help@r-project.org 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.

Reply via email to