[R] Additional field data collection
David Winsemius
dwinsemius at comcast.net
Thu Feb 4 00:31:16 CET 2010
If you really needed to automate the process, you could write a
function that looked for divisions on the x-axis where the function
"turned". I am not sure whether approxfun() realizations can be
differentiated with deriv(), but some sort application of diff and rle
would probably let you split the full range into a set of ranges
within which approxfun(y, x) would be monotonic.
--
David.
On Feb 3, 2010, at 6:06 PM, stephen sefick wrote:
> Yeah, I believe so.
>
> On Wed, Feb 3, 2010 at 4:53 PM, David Winsemius <dwinsemius at comcast.net
> > wrote:
>>
>> On Feb 3, 2010, at 5:44 PM, stephen sefick wrote:
>>
>>> 39 for right now
>>>
>>> Which, now that I look at it, doesn't seem like that many
>>> stations. I
>>> guess I am looking for a general solution because I will also have
>>> to
>>> do a similar thing for another analysis... so 36 more... grand total
>>> 72.
>>
>> So manageable for doing some mammalian guidance to the software?
>>
>> ==
>> David.
>>
>>>
>>> Stephen
>>>
>>> On Wed, Feb 3, 2010 at 4:14 PM, David Winsemius <dwinsemius at comcast.net
>>> >
>>> wrote:
>>>>
>>>> On Feb 3, 2010, at 3:36 PM, stephen sefick wrote:
>>>>
>>>>> This is a subset of a much larger dataframe. I would like to be
>>>>> able
>>>>> to automate finding the pair of x, y coordinates where the line
>>>>> crosses zero agian
>>>>>
>>>>> x <- (structure(list(bankfull_depths_m = c(0, 0.17, 0.38, 0.37,
>>>>> 0.36,
>>>>> 0.39, 0.47, 0.48, 0.19, 0.05, -0.05, -0.09), measurment_num_m =
>>>>> c(0.2,
>>>>> 0.4, 0.6, 0.8, 1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.4)), .Names =
>>>>> c("bankfull_depths_m",
>>>>> "measurment_num_m"), class = "data.frame", row.names = 97:108))
>>>>>
>>>>> qplot(measurment_num_m, bankfull_depths_m, data=x)
>>>>>
>>>>> in this case it is 2.1, 0
>>>>
>>>> I cannot quite get there with a naive application of approxfun
>>>> using
>>>> "reversed arguments", since the inverse function that would be
>>>> created is
>>>> not a legitimate function. I can do it in segments, though:
>>>>
>>>>> y.x <- approxfun(x=x$bankfull_depths_m[9:12],
>>>>> y=x$measurment_num_m[9:12])
>>>>> y.x(0)
>>>>
>>>> [1] 2.1 # so you can do it piecewise in regions where the x-y
>>>> function
>>>> is
>>>> monotonic
>>>>
>>>>> y.x <- approxfun(x=x$bankfull_depths_m, y=x$measurment_num_m)
>>>>> y.x(0)
>>>>
>>>> [1] 0.2 # an almost trivial result at the LHS of the range.
>>>>
>>>> You could also try to do a Newtonian walk (at least that is my
>>>> guess for
>>>> the
>>>> underlayment of uniroot() ) along the result of the the unreversed
>>>> arguments.
>>>>
>>>>> x.y <- approxfun(y=x$bankfull_depths_m, x=x$measurment_num_m)
>>>>> uniroot(x.y, range(x$measurment_num_m) )
>>>>
>>>> $root
>>>> [1] 0.2
>>>>
>>>> $f.root
>>>> [1] 0
>>>>
>>>> $iter
>>>> [1] 0
>>>>
>>>> $estim.prec
>>>> [1] 0
>>>>
>>>> # That was the first root and this is the second.
>>>>
>>>>> uniroot(x.y, c(1, 2.3) )
>>>>
>>>> $root
>>>> [1] 2.1
>>>>
>>>> $f.root
>>>> [1] 0
>>>>
>>>> $iter
>>>> [1] 3
>>>>
>>>> $estim.prec
>>>> [1] 0.01162791
>>>>
>>>> So you still need to apply some guidance to the functions.
>>>>
>>>> --
>>>> david
>>>>
>>>>
>>>>>
>>>>> I need a way to process a whole bunch of data points, and I am
>>>>> at a
>>>>> loss. Thanks for any help.
>>>>> regards,
>>>>
>>>> Whole bunch??? Can you be any more vague, please?
>>>> --
>>>>
>>>> David Winsemius, MD
>>>> Heritage Laboratories
>>>> West Hartford, CT
>>>>
>>>> ______________________________________________
>>>> R-help at 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.
>>>>
>>>
>>>
>>>
>>> --
>>> Stephen Sefick
>>>
>>> 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
>>
>> David Winsemius, MD
>> Heritage Laboratories
>> West Hartford, CT
>>
>> ______________________________________________
>> R-help at 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.
>>
>
>
>
> --
> Stephen Sefick
>
> 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
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list