MergeRangeCategories: Automatically combine factor levels whose levels represent...

View source: R/mergecategoriescontainingranges.R

MergeRangeCategoriesR Documentation

Automatically combine factor levels whose levels represent ranges.

Description

Create new factor variables from existing factors whose labels contain numeric ranges, like 18 to 24 or $2,000 to $3,000, which are as even as possible.

Usage

MergeRangeCategories(
  input.data,
  num.categories = 2,
  method = c("even.proportions", "even.ranges"),
  grouping.mark = ",",
  decimals.mark = ".",
  lower.bound = "",
  upper.bound = ""
)

Arguments

input.data

A data.frame or vector containing factors to be merged.

num.categories

An integer indicating the number of categories in the new factors, excluding any levels that do not contain range information.

method

A character indicating how the merging is to be performed. The available options are "even.proportions" and even.ranges.

grouping.mark

A character indicating how thousands are grouped within the labels of the input data. Usally a comma, but sometimes a period for example in European locales.

decimals.mark

A character indicating how decimal values are separated in the input data. Usually a period.

lower.bound

A numeric value which indicates the lower bound of the numeric ranges when the number is not explicitly included in the level labels. For example, when the lowest level is "Under 18", you may wish to specify that the lowest possible value in this level is 12, 15, 0, etc. Default value of "" means that an estimate will be used based on the width of the next highest range.

upper.bound

As above, for the higher end of the range.

Value

A data frame containing the new factor variables as columns.


Displayr/flipTransformations documentation built on Feb. 26, 2024, 12:47 a.m.