ScaleVariableSet: Scale a Displayr Variable Set

View source: R/scalevariableset.R

ScaleVariableSetR Documentation

Scale a Displayr Variable Set

Description

Given a Displayr Variable Set or Q Question, performs a specified scaling on the data; first converting any categorical variables to numeric as necessary.

Usage

ScaleVariableSet(
  data,
  type = c("standardize", "center", "unit", "rank"),
  within.case = FALSE
)

Arguments

data

A Displayr Variable Set or Q Question: A numeric or factor vector, or a data.frame containing either all numeric columns or all factor columns.

type

Character string specifying the type of scaling to perform; one of "standardize" (the default), "center", "rank", or "unit".

within.case

Logical; should the scaling be performed within case (rows) or variables (columns). An error is thrown if TRUE and data contains only one variable.

Value

A numeric vector if data contains only a single variable or a data.frame containing the scaled values.

See Also

scale, numbersFromCategoricalVariableSets

Examples

x <- structure(c(1, 2, 3, 4, 5), questiontype = "Number",
               dataset = "dat", name = "x", label = "x", question = "x")

ScaleVariableSet(x, type = "unit")

Displayr/flipTransformations documentation built on Feb. 26, 2024, 12:47 a.m.