[R] Question regarding R plot
Akito Y. Kawahara
akito.kawahara at gmail.com
Sat Apr 17 16:30:56 CEST 2010
Hi, I am new to R, and have a quick question regarding an R script
that I received from a kind colleague.
I am trying to determine the "peak" (maximum value) of the graph that
is plotted when executing the following. There is an input file called
"rates_values.txt" which begins as:
rateValue
0.375693
0
1.71274
0
0
1.02832
0
0.16343
1.02349
0
0
1.47258
0.703522
0.390541
1.83415
The script, below, must run with the rates_values.txt in the same dir.
#-------
rates<-read.table("rates_values.txt",header=T)
attach(rates)
scores<-function(x){
l<-length(rateValue)
total<-0
for(i in 1:l){
value<-16*rateValue[i]*rateValue[i]*x*exp(-4*rateValue[i]*x)
total<-total+value
}
return(total)
}
#-------
#preparing the plot
linewidth=3
linetype=3
color="blue"
xvalue=0.5
plot(scores,xvalue,0,type="n",font.axis=2,xlim=c(xvalue,0))
curve(scores,xvalue,add=TRUE,col=color,lty=linetype,lwd=linewidth,xlim=c(xvalue,0))
#-------
Can anyone help me figure out how to determine the peak (maximum
"scores") value in the plot that is generated? It should be about 11.7
but I would like to get an exact value. This should be a relatively
easy question, but I'm new to R, and what I have tried doesn't seem to
work.
Thanks!
More information about the R-help
mailing list