TidyRawData: Tidy Data From Displayr

View source: R/tidyrawdata.R

TidyRawDataR Documentation

Tidy Data From Displayr

Description

Tidies a data frame, by applying subets, weights, removing duplicate variables, and dealing with missing values.

Usage

TidyRawData(
  data,
  as.numeric = FALSE,
  as.binary = FALSE,
  subset = NULL,
  weights = NULL,
  missing = "Exclude cases with missing data",
  error.if.insufficient.obs = TRUE,
  remove.missing.levels = TRUE,
  extract.common.lab.prefix = FALSE,
  auto.correct.class = FALSE
)

Arguments

data

A data.frame.

as.numeric

If TRUE, converts factors into numeric variables.

as.binary

If TRUE, unordered factors are represented as dummy variables. Otherwise, they are represented as sequential integers. Only applied if as.numeric == TRUE.

subset

An optional vector specifying a subset of observations to be used in the fitting process, or, the name of a variable in data. It may not be an expression.

weights

An optional vector of sampling weights, or, the name of a variable in data. It may not be an expression.

missing

character; One of "Error if missing data", "Exclude cases with missing data" (the default, which is equivalent to 'complete.cases'), and "Use partial data", which removes no data.

error.if.insufficient.obs

Throw an error if there are more variables than observations.

remove.missing.levels

Logical; whether levels are removed if they do not occur in the observed data.

extract.common.lab.prefix

logical; if true, ExtractCommonPrefix will be used to attempt to extract the common prefix from the data labels, and if one exists, the shortened variable names without the prefix will be used for names in the returned data.frame.

auto.correct.class

If TRUE, the class of each variable is automatically inferred and corrected if required.

Value

A data.frame containing the filtered raw data, which has an attribute called "weights", containing the (filtered) vector of weights. If extract.common.lab.prefix is TRUE and a common label prefix is found, it will be return in an attribute called "label.prefix".

See Also

ExtractCommonPrefixFromLabels


Displayr/flipData documentation built on March 2, 2024, 3:49 a.m.