[R] loess line predicting number where the line crosses zero twice

stephen sefick ssefick at gmail.com
Fri Jul 16 01:33:21 CEST 2010


These data represent stream channel cross-sectional surveys.  I would
like to be able to find the measurement on the tape (measure) where
the Bank Full Depth (bkf_depths) is 0.  This will happen twice because
the channel has two sides.  I thought fitting a loess line to these
data and then predicting the measurment number would do it.  I was
wrong.  Below is my failed attempt.  My naive thought is this - I
would like to run my finger along this line and when it hits zero I
would like to pick out the value of measure. This should happen twice.
 Any help would be greatly appreciated!

w <- (structure(list(measure = c(0, 0.2, 0.4, 0.6, 0.8, 1, 1, 1.2,
1.4, 1.6, 1.8, 2, 2.2, 2.4, 2.6, 2.8, 3, 3.2, 3.4, 3.6, 3.8,
4, 4.2, 4.4, 4.6, 4.8, 4.8, 4.84, 5, 5.2, 5.4, 5.6, 5.68), bkf_depths = c(0,
0.44, 0.46, 0.66, 0.9, 1.1, 1.1, 1.2, 1.3, 1.33, 1.36, 1.36,
1.36, 1.38, 1.38, 1.36, 1.36, 1.38, 1.37, 1.37, 1.34, 1.32, 1.36,
1.35, 1.36, 1.4, 1.4, 1.3, 0.7, 0.57, 0.21, -0.05, -0.12)), .Names =
c("measure",
"bkf_depths"), row.names = c(32L, 1L, 2L, 3L, 4L, 5L, 29L, 6L,
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L,
20L, 21L, 22L, 23L, 31L, 24L, 30L, 25L, 26L, 27L, 28L, 33L), class =
"data.frame")
)

plot(w[,"bkf_depths"]~w[,"measure"])
lines(loess(w[,"bkf_depths"]~w[,"measure"]))

#this is what I tried and there should be two 0s one at the left side
of the graph and one at the right side
predict(loess(w[,"measure"]~w[,"bkf_depths"]), 0)


kindest regards,


-- 
Stephen Sefick
____________________________________
| Auburn University                                   |
| Department of Biological Sciences           |
| 331 Funchess Hall                                  |
| Auburn, Alabama                                   |
| 36849                                                    |
|___________________________________|
| sas0025 at auburn.edu                             |
| http://www.auburn.edu/~sas0025             |
|___________________________________|

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

                                -K. Mullis



More information about the R-help mailing list