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

change_scale

Rescale a numeric variable


Description

Rescale a numeric variable to a new range.

Usage

change_scale(x, ...)

## S3 method for class 'numeric'
change_scale(x, to = c(0, 100), range = NULL, verbose = TRUE, ...)

## S3 method for class 'grouped_df'
change_scale(
  x,
  select = NULL,
  exclude = NULL,
  to = c(0, 100),
  range = NULL,
  ...
)

## S3 method for class 'data.frame'
change_scale(
  x,
  select = NULL,
  exclude = NULL,
  to = c(0, 100),
  range = NULL,
  ...
)

Arguments

x

Object.

...

Arguments passed to or from other methods.

to

New range of values of the data after rescaling.

range

Initial (old) range of values. If NULL, will take the range of data.

verbose

Toggle warnings and messages on or off.

select

Character vector of column names. If NULL (the default), all variables will be selected.

exclude

Character vector of column names to be excluded from selection.

Value

A rescaled object.

See Also

Other transform utilities: normalize(), ranktransform(), standardize()

Examples

change_scale(c(0, 1, 5, -5, -2))
change_scale(c(0, 1, 5, -5, -2), to = c(-5, 5))

head(change_scale(trees))

effectsize

Indices of Effect Size and Standardized Parameters

v0.4.4-1
GPL-3
Authors
Mattan S. Ben-Shachar [aut, cre] (<https://orcid.org/0000-0002-4287-4801>), Dominique Makowski [aut] (<https://orcid.org/0000-0001-5375-9967>), Daniel Lüdecke [aut] (<https://orcid.org/0000-0002-8895-3206>), Indrajeet Patil [ctb] (<https://orcid.org/0000-0003-1995-6531>, @patilindrajeets), Ken Kelley [ctb], David Stanley [ctb]
Initial release

We don't support your browser anymore

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