Skip to contents

[Deprecated]

This function was deprecated because we realized that it's a special case of the cut function.

Usage

egen(data, var, at = NULL, label = NULL, new_var = NULL, ...)

Arguments

data

data.frame

var

existing variable

at

either a number or a numeric vector

label

Labels for the groups

new_var

Name of the new variable

...

Additional arguments to be passed to cut

See also

Examples

data <- data.frame(x = 1:10)
egen(data, x, at = c(3, 7), label = c("low", "medium", "high"))
#> Warning: `egen()` was deprecated in mStats 3.4.0.
#>  Please use `cut()` instead.
#>         x
#> 1     low
#> 2     low
#> 3  medium
#> 4  medium
#> 5  medium
#> 6  medium
#> 7    high
#> 8    high
#> 9    high
#> 10   high
egen(data, x, at = c(3, 7), label = c("low", "medium", "high"), new_var = "group")
#>     x  group
#> 1   1    low
#> 2   2    low
#> 3   3 medium
#> 4   4 medium
#> 5   5 medium
#> 6   6 medium
#> 7   7   high
#> 8   8   high
#> 9   9   high
#> 10 10   high