Bug 14864 - [PATCH] (5 lines) plot.stepfun ignores documented xval argument
[PATCH] (5 lines) plot.stepfun ignores documented xval argument
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: Misc
R-devel (trunk)
All All
: P5 normal
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-29 04:24 UTC by Murray Stokely
Modified: 2012-03-29 14:07 UTC (History)
0 users

See Also:


Attachments
5 line patch to get this function to use the xval argument. No change when xval not specified. (1.10 KB, patch)
2012-03-29 04:24 UTC, Murray Stokely
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Murray Stokely 2012-03-29 04:24:38 UTC
Created attachment 1283 [details]
5 line patch to get this function to use the xval argument.  No change when xval not specified.

Ran into this bug on R 2.14.2 on Linux today, but it appears to be universal and to have existed since plot.stepfun was first imported to its current location in the stats library in 2003.

To reproduce:

plot(ecdf(1:1000), xval=seq(0,1000,length.out=10))

which calls :

plot.stepfun(ecdf(1:1000), xval=seq(0,1000,length.out=10))

?plot.stepfun indicates that xval can be used to specify a numeric vector of abscissa values at which to evaluate ‘x’.  However, the implementation ignores it for this purpose and always evaluates x at knots(x).

The attached 5-line patch has no effect in the default codepath where xval is not specified, but it now allows xval to be used as documented.

This came up as problematic for me when creating ecdfs of very large datasets and generating PDFs for a report.  The resulting files were 15MB+ for a simple CDF, because far more detail was included than the eye could perceive.  The xval argument now lets me set a more reasonable default and greatly reduce the size of generated vector plots.

http://people.freebsd.org/~murray/patches/plot-stepfun-abscissa.diff
Comment 1 Brian Ripley 2012-03-29 14:07:36 UTC
Changed for 2.15.0 patched.