normalize_DF: Normalize variable

normalize_DFR Documentation

Normalize variable

Description

Normalize variable in a data frame

Usage

normalize_DF(
  data,
  var.name,
  method = "mean",
  norm.number,
  return = "add.end",
  digits = 2
)

Arguments

data

data frame with numeric variable that should be normalized

var.name

character; data frame column name with numeric variable that should be normalized

method

character; normalization method; possible values are: "mean" (normalize to mean), "median" (normalize to median), "number" (normalize to given number)

norm.number

numeric; a value to normalize to (if method = "number")

return

character; return object; possible values are: "vector" (return a vector of normalized values), "replace" (replace var.name values with normalized values in data frame), "add.near" (add normalized values next to var.name values in data frame), "add.end" (add normalized values as the latter column in data frame)

digits

integer; number of decimal places to round the normalized value

Details

This function scales variable to a range of (0-1), where 1 get values that are the most close to mean, median or given number. See normalize for details.

var.name must be exact column name as in data frame.

Value

Vector or data frame with normalized values.

Author(s)

Elena N. Filatova

Examples

data <- data.frame (N = 1:5, temperature = c(37.5, 36.6, 41.2, 38.8, 36.7),
                name = c("Bob", "Kate", "Steve", "Sonya", "Mary"))
normalize_DF (data = data, var.name = "temperature", method = "mean", return = "vector")
normalize_DF (data = data, var.name = "temperature", method = "mean", return = "replace")
normalize_DF (data = data, var.name = "temperature", method = "mean", return = "add.near")
normalize_DF (data = data, var.name = "temperature", method = "number",
            norm.number = 36.6, return = "add.end")


disprose documentation built on March 19, 2022, 2:15 a.m.