Re: [R] union of list objects if objects intersect

2013-11-10 Thread Hermann Norpois
I guess I found a solution though it is not very elegant. Hermann snp.block <- function (huz) { for (i in names (huz)) { chain1 <- huz[[i]] for (k in names (huz)) { chain2 <- huz[[k]]

Re: [R] union of list objects if objects intersect

2013-11-10 Thread Hermann Norpois
My purpose is to create chains of list objects if elements of the object overlap. If there is no overlap the object remains as it is. My plan is to identify snps that are in ld. The letters in each list object represent snps that are in ld in respect to the first snp (or letter). The first snp (or

Re: [R] union of list objects if objects intersect

2013-11-10 Thread Bert Gunter
I'll leave it to others to muddle through your code. It appears to refer to an earlier post that you did not include. Note also that you still have not specified what you want to get from your example ja list. Doing so might help you get a useful response, which mine clearly is not. Cheers, Bert

Re: [R] union of list objects if objects intersect

2013-11-10 Thread Bert Gunter
Your specification is a unclear (to me anyway): What do you want to return if the intersection is empty? What if intersect(ja[[i]], ja[[i+1]]) is empty for all i? What if length(intersect( ja[[i]], ja[[i+1]] )) ==0 but intersect(ja[[i]],ja[[i+2]]) is nonempty? Your example isn't -- you did not sp

[R] union of list objects if objects intersect

2013-11-09 Thread Hermann Norpois
Hello, I have a list called ja and I wish to unify list objects if there is some overlap. For instance something like if (length (intersect (ja[[1]], ja[[2]]) !=0) { union (ja[[1]], ja[[2]] } but of course it should work cumulatively (for larger data sets). Could you please give me a hint. Tha