Description Usage Arguments Value Examples
This function will take one or two data frames containing ages and create a distance matrix based off of the manhattan distance. Data can be entered as a single column data frame assuming years or a two column data frame with a specifier for months or year in the second column.
1 2 3 |
dat1, dat2 |
a data frame of ages |
e |
the number of years difference allowed for two entries to be the same |
extra_column |
a named list specifying the type of age represented |
a distance matrix of binary values where 0 indicates that two ages are within the given threshold of each other and 1 indicates not.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | set.seed(999)
x <- data.frame(age = rpois(5, 30), age_class = "YEAR")
y <- data.frame(age = rpois(5, 18), age_class = "MONTH")
dat <- rbind(x, y)
# Assume everything is in years
ageDists(dat[1])
# Specify year and month
ageDists(dat, extra_column = list(mo = "MONTH", yr = "YEAR"))
# Input two data sets
ageDists(x[1], y, extra_column = list(mo = "MONTH", yr = "YEAR"))
# allow ages within three years of each other to match
ageDists(dat, e = 3, extra_column = list(mo = "MONTH", yr = "YEAR"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.