[R] Does this exist: diff(range(VAR, na.rm=T))

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Wed Jun 25 21:10:04 CEST 2025


On 2025-06-25 2:11 p.m., Dennis Fisher wrote:
> Version 4.4.2
> OS X
> 
> Colleagues
> 
> I often need to determine the span of the x-variable in a graphic.
> 
> This is easy to determine with:
> 	diff(range(VAR, na.rm=T))
> 
> I am not aware of any function in base R that accomplishes this and “span” is not taken.
Then you should write one that suits your needs.  It could have just the 
line above, or you could make it fancier, expanding the range a bit like 
plot() does.

> 
> Would it be possible to add such a function?  Not a major addition but often useful.
If you think others would like to use it, then include it in a package 
and publish the package.

Duncan Murdoch



More information about the R-help mailing list