[R] howto find corresponding values in datasource?

From: Jonas Stein <news_at_jonasstein.de>
Date: Wed, 12 Mar 2008 23:09:53 +0100


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.
Received on Wed 12 Mar 2008 - 22:37:02 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 - 11: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