[R] howto find corresponding values in datasource?
bartjoosen
bartjoosen at hotmail.com
Thu Mar 13 10:20:16 CET 2008
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.
More information about the R-help
mailing list