Re: [R] question on graphs and finding area under a curve

From: Marc Schwartz <MSchwartz_at_mn.rr.com>
Date: Tue 02 Aug 2005 - 23:18:52 EST

On Tue, 2005-08-02 at 18:20 +0530, Renuka Sane wrote:
> Question on graphs:
>
> The default case for drawing a graph in R, is where a little space is left
> on the x and y axis before the first tick i.e. even if I say xlim=c(0,1) --
> there will be some space between the edge of the x-axis and where 0 is
> placed. If I want 0 on the edge, how do I do it in R?

See ?par and take note of the 'xaxs' and 'yaxs' parameters. By default, these are set to 'r', where the axes are extended by 4% in each direction. Thus, set one or both parameters to 'i' to set the axes to exactly the ranges of xlim and/or ylim as you require.

> Area under the curve:
>
> I have a 45 degree line and a curve above or below it. Is there a way in R
> to find the area between the two?

See Frank Harrell's somers2() function in the Hmisc package on CRAN. Among other things, it outputs a value "C", which is the AUC.

HTH, Marc Schwartz



R-help@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 Received on Tue Aug 02 23:22:52 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:01:07 EST