AverageByCategoricalVariable: Average of one or more numerical features by a categorical...

View source: R/DataUnderstanding.R

AverageByCategoricalVariableR Documentation

Average of one or more numerical features by a categorical (target) variable and the single 'CategoricalVariable'

Description

Average of one or more numerical features by a categorical (target) variable and the single 'CategoricalVariable'

Usage

AverageByCategoricalVariable(
  NumericalVariables,
  CategoricalVariable,
  DataFrame,
  dropNA = FALSE
)

Arguments

NumericalVariables

character. Vector of names of numerical variables.

CategoricalVariable

character. Name of single categorical (target) variable.

DataFrame

data.frame. Input data.frame. Has to contain the 'NumericalVariables'

dropNA

boolean. Drop NA values prior to analysis in numerical variable? Default is 'FALSE'

Examples

# a few numerical features
AverageByCategoricalVariable(NumericalVariables = c("Sepal.Length", "Sepal.Width"),
                             CategoricalVariable = c("Species"),
                             DataFrame = iris,
                             dropNA = TRUE)
# a single numerical feature
AverageByCategoricalVariable(NumericalVariables = c("mpg"),
                             CategoricalVariable = c("am"),
                             DataFrame = mtcars,
                             dropNA = TRUE)
# Example with NA values
AverageByCategoricalVariable(NumericalVariables = c("Ozone"),
                             CategoricalVariable = c("Month"),
                             DataFrame = airquality,
                             dropNA = FALSE)
# Drop NA values
AverageByCategoricalVariable(NumericalVariables = c("Ozone"),
                             CategoricalVariable = c("Month"),
                             DataFrame = airquality,
                             dropNA = TRUE)

masem-research/masemDataUnderstanding documentation built on May 5, 2022, 12:40 a.m.