CompositeData: An constructor function for the S4 CompositeData class

View source: R/methods.R

CompositeDataR Documentation

An constructor function for the S4 CompositeData class

Description

An constructor function for the S4 CompositeData class

Usage

CompositeData(rawdata, groups, thresholds, higherisbetter, k, rawtrans)

Arguments

rawdata

A data frame with at least one row and column

groups

an optional character vector. If omitted defaults to a character vector of all “one”s.

thresholds

an optional named list where names match the names in groups. If using defaults for groups, should name it “one”.

higherisbetter

an optional logical vector

k

an optional integer, the number of columns in the raw data

rawtrans

A list of functions to transform the raw data (and thresholds). This list should be in the same order as the variables. For variables that should not be transformed, use: function(x) x.

Value

An S4 object of class “CompositeData”

Examples

## no custom raw data transformations
d <- CompositeData(mtcars[, c("mpg", "hp", "wt", "qsec")],
  thresholds = list(one = with(mtcars, c(
    mpg = max(mpg),
    hp = max(hp),
    wt = min(wt),
    qsec = min(qsec)))
  ),
  higherisbetter = c(TRUE, TRUE, FALSE, FALSE))

## square root transform qsec
d <- CompositeData(mtcars[, c("mpg", "hp", "wt", "qsec")],
  thresholds = list(one = with(mtcars, c(
    mpg = max(mpg),
    hp = max(hp),
    wt = min(wt),
    qsec = min(qsec)))
  ),
  higherisbetter = c(TRUE, TRUE, FALSE, FALSE),
  rawtrans = list(
    mpg = function(x) x,
    hp = function(x) x,
    wt = function(x) x,
    qsec = sqrt))

## cleanup
rm(d)

pscore documentation built on May 14, 2022, 1:06 a.m.