Description Usage Arguments Value Examples
This function takes an age variable in either year form (i.e. 1995) or age form (i.e. 24) and turns it into a standard grouped age variable called AgeRange.
1 |
df |
This is the name of the dataframe with the age variable |
var |
This is the name of the age variable |
Returns a variable with the following age ranges: "18-24", "25-34", "35-44", "45-54", "55-64", "65+"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | x <- c(1989, 1972, 1994, 1954, 1977, 1962, 1945, 2000, 1965, 1969, 1973, 1991, 1974, 1987, 1969, 1981, 1959, 1980, 1949, 1975, 1985, 1952, 1959, 1973, 1968, 1973, 1998, 1991, 1991, 1972) %>%
as.data.frame() %>%
rename(
year = "."
)
age_redefine(x, year)
OR
x <- c(30,47,25, 65, 42,57,74,19,54,50,46,28,45,32,50,38,60,39,70,44,34,67,60,46,51,46,21,28,28,47) %>%
as.data.frame() %>%
rename(
year = "."
)
age_redefine(x, year)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.