On 22-Oct-09 19:03:06, Duncan Murdoch wrote: > On 22/10/2009 2:57 PM, (Ted Harding) wrote: >> A follow-up to my previous query. >> >> Say one of the results returned by contourLines() is >> >> C.W <- contourLines(....) >> >> Then C.W is a list of (in this case 28) lists, >> each of which is a list with components $level (a single number), >> $x (the x coords of the points on a contour at that level) and >> $y (the y coords). >> >> I can of course get these individually with, for the 5th one for >> instance, >> >> C.W[[5]]$level >> C.W[[5]]$x >> C.W[[5]]$y >> >> But I can't see how to obtain, in one line and without running >> a nasty loop, to get all the levels at once! >> >> In other words, I'm looking for an expression which will return >> the vector >> >> c(C.W[[1]]$level,C.W[[2]]$level,...,C.W[[28]]$level) > > sapply(C.W., function(x) x$level) > > should do it. (It will contain repeats if your contours have gaps in > them; unique() can remove those.) > > Duncan Murdoch
Excellent! That does do it. Indeed, It is precisely to identify the "broken" contours that I want the set of levels, so the repeats are what I'm looking for! Thanks Duncan, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <ted.hard...@manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 22-Oct-09 Time: 20:10:34 ------------------------------ XFMail ------------------------------ ______________________________________________ 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.