Learn R Programming

fromo (version 0.2.4)

as.centsums: Coerce to a centsums object.

Description

Convert data to a centsums object.

Usage

as.centsums(
  x,
  order = 3,
  na.rm = TRUE,
  wts = NULL,
  check_wts = FALSE,
  normalize_wts = FALSE
)

# S3 method for default as.centsums( x, order = 3, na.rm = TRUE, wts = NULL, check_wts = FALSE, normalize_wts = FALSE )

Value

A centsums object.

Arguments

x

a numeric, array, or matrix.

order

the order, defaulting to length(sums)+1.

na.rm

whether to remove NA.

wts

an optional vector of weights. Weights are ‘replication’ weights, meaning a value of 2 is shorthand for having two observations with the corresponding v value. If NULL, corresponds to equal unit weights, the default. Note that weights are typically only meaningfully defined up to a multiplicative constant, meaning the units of weights are immaterial, with the exception that methods which check for minimum df will, in the weighted case, check against the sum of weights. For this reason, weights less than 1 could cause NA to be returned unexpectedly due to the minimum condition. When weights are NA, the same rules for checking v are applied. That is, the observation will not contribute to the moment if the weight is NA when na_rm is true. When there is no checking, an NA value will cause the output to be NA.

check_wts

a boolean for whether the code shall check for negative weights, and throw an error when they are found. Default false for speed.

normalize_wts

a boolean for whether the weights should be renormalized to have a mean value of 1. This mean is computed over elements which contribute to the moments, so if na_rm is set, that means non-NA elements of wts that correspond to non-NA elements of the data vector.

Author

Steven E. Pav shabbychef@gmail.com

Details

Computes the raw sums on data, and stuffs the results into a centsums object.

Examples

Run this code
set.seed(123)
x <- rnorm(1000)
cs <- as.centsums(x, order=5)

Run the code above in your browser using DataLab