Package {normalize}


Type: Package
Title: Centering and Scaling of Numeric Data
Version: 0.1.3
Description: Provides simple methods for centering and scaling of numeric data. Columns or rows can be ignored when normalizing or be normalized jointly.
License: GPL (≥ 3)
Encoding: UTF-8
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
Imports: stats
URL: https://github.com/loelschlaeger/normalize
BugReports: https://github.com/loelschlaeger/normalize/issues
Config/roxygen2/version: 8.0.0
NeedsCompilation: no
Packaged: 2026-07-01 15:54:34 UTC; loelschlaeger
Author: Lennart Oelschläger [aut, cre]
Maintainer: Lennart Oelschläger <oelschlaeger.lennart@gmail.com>
Repository: CRAN
Date/Publication: 2026-07-02 03:50:02 UTC

normalize: Centering and Scaling of Numeric Data

Description

logo

Provides simple methods for centering and scaling of numeric data. Columns or rows can be ignored when normalizing or be normalized jointly.

Author(s)

Maintainer: Lennart Oelschläger oelschlaeger.lennart@gmail.com

Authors:

See Also

Useful links:


Normalize numeric data

Description

Center and scale vectors, matrices, data frames, or lists of these objects.

Usage

normalize(x, center = TRUE, scale = TRUE, ...)

## Default S3 method:
normalize(x, ...)

## S3 method for class 'numeric'
normalize(x, center = TRUE, scale = TRUE, ...)

## S3 method for class 'matrix'
normalize(
  x,
  center = TRUE,
  scale = TRUE,
  byrow = FALSE,
  ignore = integer(),
  jointly = list(),
  ...
)

## S3 method for class 'data.frame'
normalize(
  x,
  center = TRUE,
  scale = TRUE,
  byrow = FALSE,
  ignore = integer(),
  jointly = list(),
  ...
)

## S3 method for class 'list'
normalize(x, center = TRUE, scale = TRUE, ...)

Arguments

x

An object to be normalized.

center

[logical(1)]
Should values be centered to zero mean?

scale

[logical(1)]
Should values be scaled to unit variance?

...

Further arguments to be passed to or from other methods.

byrow

[logical(1)]
Only relevant if x has two dimensions (rows and columns).

In this case, set to TRUE to normalize row-wise or FALSE to normalize column-wise (default).

ignore

[integer()]
Only relevant if x has two dimensions (rows and columns).

Indices to leave unchanged. With byrow = TRUE, these are row indices. With byrow = FALSE, these are column indices. This is useful, for example, to keep identifier or non-numeric columns in a data frame.

jointly

[list()]
Only relevant if x has two dimensions (rows and columns).

A list of disjoint index groups to normalize jointly. With byrow = TRUE, these are row indices. With byrow = FALSE, these are column indices.

Value

A normalized version of x, preserving attributes where possible. Lists return a list with each element normalized. The centering and scaling values used are stored in the "center" and "scale" attributes where relevant.

Examples

# can normalize vectors, matrices, data.frames, and lists of such types
normalize(
  list(
    c(-3, 0, 3),
    matrix(1:12, nrow = 3, ncol = 4),
    data.frame(a = 1:3, b = 4:6, c = 7:9, d = 10:12)
  )
)

# can ignore columns (or rows)
normalize(
  data.frame(a = 1:3, b = c("A", "B", "C"), c = 7:9, d = 10:12),
  ignore = 2
)

# can normalize columns (or rows) jointly
normalize(
  matrix(1:12, nrow = 3, ncol = 4),
  jointly = list(1:2, 3:4)
)

mirror server hosted at Truenetwork, Russian Federation.