View source: R/DataUnderstanding.R
AverageByCategoricalVariable | R Documentation |
Average of one or more numerical features by a categorical (target) variable and the single 'CategoricalVariable'
AverageByCategoricalVariable( NumericalVariables, CategoricalVariable, DataFrame, dropNA = FALSE )
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' |
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.