Re: [R] ask a question about list in R project

2010-06-28 Thread Joshua Wiley
Hello, It looks to me like you want all the values of 'mylist' returned in a list except for a[i] for each element of a. In this case, length(a) = 4, so you want 4 lists. If this is not what you were trying to do, perhaps you could explain the pattern between your data and your desired output.

Re: [R] ask a question about list in R project

2010-06-28 Thread song song
I found this loop can do this. is there any simple method? rm(list=ls()) a=c(2,3,5,7) mylist=list(c(2,3),5,7) newlist=list() for (i in 1:4){ for (j in 1:length(mylist)){ newlist[[j]]=mylist[[j]] if (a[i] %in% mylist[[j]]){ newlist[[j]]=mylist[[j]][mylist[[j]]!=a[i]] if

Re: [R] ask a question about list in R project

2010-06-28 Thread David Winsemius
There was a recent fortune suggestion along the lines of any simple English sentence can probably be satisfied with a simple set of R functions without loops. In this case you appear to be forgetting the "simple English sentence" part of that formulation. -- David. On Jun 28, 2010, at 7:3

[R] ask a question about list in R project

2010-06-28 Thread song song
my list al is as below: mylist=list(c(2,3),5,7) > mylist [[1]] [1] 2 3 [[2]] [1] 5 [[3]] [1] 7 How could I get the following FOUR lists: First one [[1]] [1] 3 [[2]] [1] 5 [[3]] [1] 7 Second one [[1]] [1] 2 [[2]] [1] 5 [[3]] [1] 7 Third One [[1]] [1] 2 3 [[2]] [1] 7 Last one [[1]] [1] 2