HI,
Not sure if I understand it clearly.
Are you looking for something like this:
res1<-list()
?fun1<-function(x,res){
?for(i in 1:ncol(x)){
?res[[i]]<-list()
?res[[i]]<-combn(1:ncol(x),i)
?}
?res}
fun1(m1,res1)
[[1]]
???? [,1] [,2] [,3] [,4] [,5]
[1,]??? 1??? 2??? 3??? 4??? 5
[[2]]
???? [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]??? 1??? 1??? 1??? 1??? 2??? 2??? 2??? 3??? 3???? 4
[2,]??? 2??? 3??? 4??? 5??? 3??? 4??? 5??? 4??? 5???? 5
----------------------------------------------
-----------------------------------------------
A.K.
----- Original Message -----
From: Haris Rhrlp <haris_r_help at yahoo.com>
To: "R-help at r-project.org" <R-help at r-project.org>
Cc:
Sent: Sunday, November 18, 2012 1:21 PM
Subject: [R] i want to put the results of the list in a for loop
Dear R users,
i want to put the results of a list to a for loop.
i will give an example
m1<-matrix(rep(1,15),ncol=5)
? ind.sgn <- lapply(1:ncol(m1), combn, x = ncol(m1))
?ind.sgn
[[1]]
???? [,1] [,2] [,3] [,4] [,5]
[1,]??? 1??? 2??? 3??? 4??? 5
[[2]]
???? [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]??? 1??? 1??? 1??? 1??? 2??? 2??? 2??? 3??? 3???? 4
[2,]??? 2??? 3??? 4??? 5??? 3??? 4??? 5??? 4??? 5???? 5
[[3]]
???? [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]??? 1??? 1??? 1??? 1??? 1??? 1??? 2??? 2??? 2???? 3
[2,]??? 2??? 2??? 2??? 3??? 3??? 4??? 3??? 3??? 4???? 4
[3,]??? 3??? 4??? 5??? 4??? 5??? 5??? 4??? 5??? 5???? 5
[[4]]
???? [,1] [,2] [,3] [,4] [,5]
[1,]??? 1??? 1??? 1??? 1??? 2
[2,]??? 2??? 2??? 2??? 3??? 3
[3,]??? 3??? 3??? 4??? 4??? 4
[4,]??? 4??? 5??? 5??? 5??? 5
[[5]]
???? [,1]
[1,]??? 1
[2,]??? 2
[3,]??? 3
[4,]??? 4
[5,]??? 5
I want in any of theses results to put them in for loop
each time to multiply a column as indicates the list. for example
first it will multiply each column
after will multiply two columns as in [[2]]
after will multiply three columns as in [[3]]etc
any help will be welcome
??? [[alternative HTML version deleted]]
______________________________________________
R-help at 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.