Re: [R] howto find corresponding values in datasource?

From: bartjoosen <bartjoosen_at_hotmail.com>
Date: Thu, 13 Mar 2008 02:20:16 -0700 (PDT)

The x coordinate of the max y value:

x[which.max(mydiff$y)]

Jonas Stein wrote:
>
> Hi,
>
>
> i am sure, that this is a noob-question, but i have searched for
> hours without any good result.
>
> I want to draw a vertical line through the maximum of the first
> derivation.
>
> Here is a small example.
>
> --8<-----[mydata.csv]--------------------------------
> H M
> 1 15
> 2 22
> 3 23
> 4 17
> 5 10
> --8<-----[myquestion.R]------------------------------
> mydata <- read.table("mydata.csv", header=TRUE, sep="\t")
>
> attach(mydata)
> # make a smooth fit through the points and calculate the first derivation
> d/dx
> myspl <- smooth.spline(H, M, all.knots = FALSE, nknots = 10, spar=0.5)
> mydiff <- predict(myspl, 0:max(H), deriv=1)
>
>
> # find the maximum peak max(y)
> y1=y2= max(mydiff$y)
>
> # now i want to plot a line through the maximum of the derivation
> # how can i get the x-coordinate?
> # segments(x1,y1,x2,y2)
>
> detach()
> --8<-------------------------------------
>
> Thank you,
>
> --
> Jonas Stein
>
> ______________________________________________
> 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.
>
>

-- 
View this message in context: http://www.nabble.com/howto-find-corresponding-values-in-datasource--tp16016130p16023738.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.
Received on Thu 13 Mar 2008 - 09:29:59 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 13 Mar 2008 - 09:30:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive