Learn R Programming

wrMisc (version 2.1.0)

adjBy2ptReg: Adjust Values By Two-Point Regression

Description

This function performs linear rescaling of numeric data based on specified limits (ie a specified window). Values are adjusted to fit within a target range defined by `regrTo`.

Usage

adjBy2ptReg(
  dat,
  lims,
  regrTo = c(0.1, 0.9),
  refLines = NULL,
  silent = FALSE,
  debug = FALSE,
  callFrom = NULL
)

Value

A numeric vector or matrix with adjusted values.

Arguments

dat

A numeric vector or matrix of values to adjust.

lims

A list of two numeric vectors, each of length 1 or 2, representing the lower and upper limits for rescaling. Example: `lims = list(c(5, 9), c(60, 90))`.

regrTo

A numeric vector of length 2 defining the target range for rescaling (default: `c(0.1, 0.9)`).

refLines

Optional numeric or character vector specifying reference lines (rows) in `dat` to use for rescaling. If `NULL`, all rows are used.

silent

Logical. If `TRUE`, suppresses messages (default: `FALSE`).

debug

Logical. If `TRUE`, prints debugging messages (default: `FALSE`).

callFrom

Character string for tracking messages (default: `NULL`).

Details

Since this function shares sigificant overlap with scaleXY (which has more advanced options) it is rather suggested to use _scaleXY()_ instead. The function _adjBy2ptReg()_ will may deprecated in the future.

Examples

Run this code
set.seed(2016); dat1 <- round(runif(50, 0, 100), 1)
adjBy2ptReg(dat1, lims = list(c(5, 9), c(60, 90)))
plot(dat1, adjBy2ptReg(dat1, lims=list(c(5,9), c(60,90))))

Run the code above in your browser using DataLab