Re: [R] Union of list elements

2004-12-18 Thread Jean Eid
Can't you turn the lists into data frames issue unique and force them back to lists. Here's the code: L <- list(c("a1","a3","a4"), c("a1","a4","a5"), c("a1","a5","a6")) M <- list(c("a1","a3","a4"), c("a2","a4","a5"), c("a1","a5","a6"), c("a7", "a1", "a4")) LL <- as.data.frame(I(L)) MM <- as.data

[R] Union of list elements

2004-12-17 Thread Patrick Meyer
Thanx to all of you who helped me with my sets problem. ;-) Patrick __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Re: [R] Union of list elements

2004-12-17 Thread Gabor Grothendieck
Patrick Meyer internet.lu> writes: : : It does not exactly do what it is meant to... Instead of breaking down, : my code is looping forever now... I think I will have a deeper look at : it tomorrow... : : In fact, I have two lists: let's say L and N. : : An elements (or set) of N must be add

[R] Union of list elements

2004-12-17 Thread Patrick Meyer
It does not exactly do what it is meant to... Instead of breaking down, my code is looping forever now... I think I will have a deeper look at it tomorrow... In fact, I have two lists: let's say L and N. An elements (or set) of N must be added to L, if and only if it is not a subset of an eleme

Re: [R] Union of list elements

2004-12-17 Thread Gabor Grothendieck
Patrick Meyer internet.lu> writes: : : Thank you Gabor. : : But I have a problem with the beginning of my algorithm, where the list : you call L is empty... then the code breaks down... It says: : : "Error in any(...,na.rm = na.rm) : incorrect argument type" : : How can I handle this? : Go

RE: [R] Union of list elements

2004-12-17 Thread Liaw, Andy
Initialize the list with the first vector, instead of an emtry list, if you can. Andy > From: Patrick Meyer > > Thank you Gabor. > > But I have a problem with the beginning of my algorithm, > where the list > you call L is empty... then the code breaks down... It says: > > "Error in any(...,

Re: [R] Union of list elements

2004-12-17 Thread Patrick Burns
Andy, I don't think that you should be so quick to put yourself down. Your solution just needs a 'sort' put in it so that order doesn't matter. With Andy's solution the object can now be a character vector rather than a list and 'match' can be used for testing new items: newitems <- unique(newitems

[R] Union of list elements

2004-12-17 Thread Patrick Meyer
Thank you Gabor. But I have a problem with the beginning of my algorithm, where the list you call L is empty... then the code breaks down... It says: "Error in any(...,na.rm = na.rm) : incorrect argument type" How can I handle this? Thank you very much for your help Patrick __

RE: [R] Union of list elements

2004-12-17 Thread Liaw, Andy
> From: Gabor Grothendieck > > Pat Meyer hotmail.com> writes: > > : > : Hi, > : > : First of all, let me thank you all for replying so rapidly > to my first > : question on this list. It was very very helpfull... and I'm > learning R > : faster and faster. > : > : I just encountered a sec

RE: [R] Union of list elements

2004-12-17 Thread Liaw, Andy
All the ways of doing such things (that I know of) in R only work on atomic objects, so one way to do it is, again, concatenate the vectors into one string, then do the comparison: > lst = list(c("a1", "a3", "a4"), c("a1", "a4", "a5"), c("a1", "a5", "a6")) > lst.vec <- sapply(lst, paste, collapse=

Re: [R] Union of list elements

2004-12-17 Thread Gabor Grothendieck
Pat Meyer hotmail.com> writes: : : Hi, : : First of all, let me thank you all for replying so rapidly to my first : question on this list. It was very very helpfull... and I'm learning R : faster and faster. : : I just encountered a second problem, which may also have a simple solution. : :

[R] Union of list elements

2004-12-17 Thread Pat Meyer
Hi, First of all, let me thank you all for replying so rapidly to my first question on this list. It was very very helpfull... and I'm learning R faster and faster. I just encountered a second problem, which may also have a simple solution. Here it is: In my program, a vector is a set of objects

[R] Union of list elements

2004-12-17 Thread Pat Meyer
__ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html