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

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Wed Jun 25 21:06:00 CEST 2025


   Not speaking for R-core, but the general answer to "could we include 
this simple helper function in base R?" is "no, put it in a package or 
in your own set of source()d helper functions; if it turns out to be 
incredibly useful we might add it somewhere down the line".

    You could ask to have it added to the `gtools` package, which has 
been around for a while and has no strong dependencies ... 
https://github.com/r-gregmisc/gtools/issues

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.
> 
> Would it be possible to add such a function?  Not a major addition but often useful.
> 
> Dennis
> 
> Dennis Fisher MD
> P < (The "P Less Than" Company)
> Phone: 1-415-307-4791
> www.PLessThan.com
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Dr. Benjamin Bolker
Professor, Mathematics & Statistics and Biology, McMaster University
Director, School of Computational Science and Engineering
 > E-mail is sent at my convenience; I don't expect replies outside of 
working hours.



More information about the R-help mailing list