[R] Qurey : How to add trendline( st. line) in Graph

Sean O'Riordain seanpor at acm.org
Mon Jun 19 14:10:09 CEST 2006


lines(predict(lm(g~f))~f,lty=2)
or if its a curvy line you're looking for...
lines(predict(loess(g~f))~f,lty=3)


On 19/06/06, priti desai <priti.desai at kalyptorisk.com> wrote:
> How to add trendline (i.e. straight line passing through maximum points)
> in graph.
> I have worked on the data given below.
> Please tell me how to add trendline in the graph.
>
> The script is as follows
>
> =================================== start
> ====================================================
>
> # The data is as follows
>
> data <- c( 0.01,  0.02, 0.04, 0.13,  0.17 , 0.19 , 0.21 , 0.27 , 0.27 ,
> 0.28,  0.29,  0.37,
>            0.41,  0.49,  0.51,  0.52,  0.54,  0.57,  0.62,  0.63,  0.68,
> 0.73,  0.74, 0.79,
>            0.81,  0.81,  0.82,  0.86,  0.94,  0.96,  1.02,  1.10,  1.10,
> 1.20,  1.29,  1.36,
>            1.40,  1.41,  1.44,  1.45,  1.62,  1.67,  1.69,  1.78,  1.82,
> 2.11,  2.13,  2.14,
>            2.24,  2.29,  2.34, 2.40,  2.46,  2.70,  2.83,  2.98,  3.00,
> 3.30,  3.53,  3.70,
>            3.86,  3.90,  3.91,  3.98,  5.01,  5.23,  6.05,  6.12, 10.41,
> 10.73)
>
> # P-P plot
> average       <- mean(data)
> lambda        <- (1/average)
> e             <- c(1:70)
> f             <- c((e-.5)/70)
> Fx            <- c(1 - exp(-lambda*data))
> g             <- sort(Fx)
> plot(f,g)
>
> ===================================== end
> ====================================================
>
> Awaiting your positive reply.
>
> Regards.
> Priti.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



More information about the R-help mailing list