[R] howto find corresponding values in datasource?

Jonas Stein news at jonasstein.de
Wed Mar 12 23:09:53 CET 2008


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



More information about the R-help mailing list