Learn R Programming

quickcode (version 1.0.6)

sub.range: Calculate the Range Difference of a Numeric Vector

Description

This function calculates the difference between the maximum and minimum values of a numeric vector.

Usage

sub.range(x)

Value

A numeric value representing the difference between the maximum and minimum values of the input vector. Returns `NA` if the input is empty or contains only `NA` values.

Arguments

x

A numeric vector for which the range difference is to be calculated.

Examples

Run this code
# Example with a numeric vector
numeric_vector <- c(1, 5, 3, 8, 2)
sub.range(numeric_vector)

# Example with missing values
sub.range(c(NA, 4, 7, NA, 10))

Run the code above in your browser using DataLab