Description Usage Arguments Details Author(s) See Also Examples
egen
transforms a numeric vector to a factor vector.
1 |
x |
numeric vector |
cut |
either a single number or a numeric vector. |
labels |
specify to name the factor levels. |
na.rm |
A logical value to specify missing values |
egen
allows easy conversion of a numeric vector to factor.
Cut-off Intervals If the interval is not specified, it is cut at an interval of 10. Otherwise, it is divided into equal cut-off points by specified number.
Labelling If not specified, the labels are constructed in the format: variable name + "." + "cut-off intervals".
Myo Minn Oo (Email: dr.myominnoo@gmail.com | Website: https://myominnoo.github.io/)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | set.seed(1)
age <- round(c(rnorm(100, 45, 20), rep(NA, 20)),0)
summary(age)
egen(age)
egen(age, cut = 20)
egen(age, cut = c(1, 20, 40))
egen(age, cut = c(1, 20, 40), labels = c("young", "middle", "old"))
egen(age, cut = c(1, 20, 40, 60, 100))
## remove missing value
egen(age, cut = 20, na.rm = TRUE)
egen(age, cut = c(1, 20, 40), na.rm = TRUE)
egen(age, cut = c(1, 20, 40), labels = c("young", "middle", "old"), na.rm = TRUE)
egen(age, cut = c(1, 20, 40, 60, 100), na.rm = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.