[R] Does this exist: diff(range(VAR, na.rm=T))
Dennis Fisher
||@her @end|ng |rom p|e@@th@n@com
Wed Jun 25 21:34:46 CEST 2025
you are missing the point:
span(…)
requires less typing than
diff(range(….))
just like
paste0
simplifies use of the paste command
Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-415-307-4791
www.PLessThan.com
> On Jun 25, 2025, at 12:32 PM, Ebert,Timothy Aaron <tebert using ufl.edu> wrote:
>
> I do not see the problem.
> In base R
> Min <- min(var, na.rm=T)
> Max <- max(var, na.rm=T)
> Span <- c(Min, Max)
>
> Is the same output as
> Span <- range(var, na.rm=T)
>
> diff(range(var, na.rm=T)) returns Max - Min
>
> range() returns a vector with two values, the minimum and the maximum.
> What should the function "span" do that is not already done?
>
> Tim
>
> -----Original Message-----
> From: R-help <r-help-bounces using r-project.org <mailto:r-help-bounces using r-project.org>> On Behalf Of Dennis Fisher
> Sent: Wednesday, June 25, 2025 2:11 PM
> To: r-help <r-help using r-project.org <mailto:r-help using r-project.org>>
> Subject: [R] Does this exist: diff(range(VAR, na.rm=T))
>
> [External Email]
>
> 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
> http://www.plessthan.com/
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org <mailto: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.
[[alternative HTML version deleted]]
More information about the R-help
mailing list