aggregate_columns: Aggregate multiple columns into one.

Description Usage Arguments Value Examples

View source: R/aggregate_columns.R

Description

Multiple columns are added together, or the mean is taken to create a new columns. Used can also choose to delete the original columns.

Usage

1
aggregate_columns(x, columns, new_colname, mode = "sum", delete = FALSE)

Arguments

x

Any nonempty dataframe.

columns

Names of the columns to be aggregated.

new_colname

How to name the new columns

mode

Choose "sum" to take sum, or "mean" to take the mean.

delete

Choose TRUE to drop the original rows from the dataframe, or FALSE to retain them.

Value

Returns the dataframe with the new column included.

Examples

1
aggregate_columns(mtcars, c("vs", "cyl", "mpg"), "meaningless_mean", mode = "mean")

julianbarg/DataAnalysisTools documentation built on April 9, 2020, 11:43 a.m.