Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

select.range

Select values from a vector depending on a range in a second vector.


Description

select.range accepts two vectors of paired observations and returns a vector of observations from data. The observations returned are those for which the paired values in groupvec are within the range specified by min and max. NOTE: The in-range condition is greater than or equal to min and less than max. This allows contiguous ranges to be specified without returning the same value in two sets.

Usage

select.range(data, groupvec, min, max)

Arguments

groupvec

A vector of observations to be used for grouping.

min

The minimum value of the range.

max

The maximum value of the range.

data

A numeric vector of observations.

Value

The subset of observations from data is returned invisibly.

Author(s)

??

Examples

testvec <- c(2.1,4.3,3.2,5.1,4.2,5.7,7.1,6.5,4.1,5,6,8,7,9 ,8 ,NA,NA)
agevec  <- c(10 ,13 ,14 ,25 ,29 ,32 , 34, 45, 48, 55, 62,67,69,70,74)
select.range(testvec,agevec,25,34.5) #  5.1 4.2 5.7 7.1

cwhmisc

Miscellaneous Functions for Math, Plotting, Printing, Statistics, Strings, and Tools

v6.6
GPL (>= 2)
Authors
Christian W. Hoffmann
Initial release
2018-08-24, 10:40:10

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.