cap_between: Cap numeric values between two values

Description Usage Arguments Examples

Description

This function capps the lowest and highest values of a numeric vector between specified values. It can be used both with numeric vectors or data frames with mutate or map_at. If no floor and roof values are provided the function will return exactly the same result as input values.

Usage

1
cap_between(x, floor = NA, roof = NA)

Arguments

x

A vector or data frame column

floor

A bottom number. Defaults to NA

roof

A top number. Defaults to NA

Examples

1
2
3
4
5
6
7
x <- seq(1, 100, 1)
cap_between(x, 40, 60)

data <- data_frame(x = seq(1, 100, 1))

data %>%
  mutate(y = cap_between(x, 40, 60))

konradsemsch/aider documentation built on May 22, 2019, 2:40 p.m.