[R] Simple extraction of level,x,y from contourLines()

(Ted Harding) Ted.Harding at manchester.ac.uk
Thu Oct 22 20:57:15 CEST 2009


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)

(This is probably something I should already have learned from
the documentation, but I think I may have been asleep during
that class ... ).

With thanks,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 22-Oct-09                                       Time: 19:57:09
------------------------------ XFMail ------------------------------




More information about the R-help mailing list