On Sunday 07 October 2007, Gabor Grothendieck wrote: > zoo's merge can do a multiway intersection. We turn each component > of aa into the times of a dataless zoo object (assuming the elements of > each component are unique) and merge them together using all = FALSE > which will only leave those points at times in all components. Extracting > the time and stripping off the names gives the result. > > library(zoo) > as.vector(time(do.call(merge, c(lapply(aa, function(x) zoo(,x)), all = > FALSE))))
Hi Gabor, it's always good to see clever solutions. Never thought about using time series to perform intersections :) I can't reproduce your solution though: Error in rval[[1]] : subscript out of bounds The elements of each component are indeed unique; the argument all = FALSE intrigues me: which function should use it, zoo() or c() ? The result of lapply() is a list; when performing c() over that list, the argument all = FALSE does nothing but to add another branch... hmm, I should really use more time series... Adrian -- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 ______________________________________________ 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.