n_goalposts: Normalise using goalpost method

View source: R/normalise.R

n_goalpostsR Documentation

Normalise using goalpost method

Description

The distance of each value of x from the lower "goalpost" to the upper one. Goalposts are specified by gposts = c(l, u, a), where l is the lower bound, u is the upper bound, and a is a scaling parameter.

Usage

n_goalposts(x, gposts, direction = 1, trunc2posts = TRUE)

Arguments

x

A numeric vector

gposts

A numeric vector c(l, u, a), where l is the lower bound, u is the upper bound, and a is a scaling parameter.

direction

Either 1 or -1. Set to -1 to flip goalposts.

trunc2posts

If TRUE (default) will truncate any values that fall outside of the goalposts.

Details

Specify direction = -1 to "flip" the goalposts. This may be necessary depending on how the goalposts were defined.

Value

Numeric vector

Examples

x <- runif(20)
n_goalposts(x, gposts = c(0.2, 0.8, 1))


COINr documentation built on Oct. 9, 2023, 5:07 p.m.