ageDists: Create distance from age column

Description Usage Arguments Value Examples

Description

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.

Usage

1
2
3
ageDists(dat1, dat2 = NULL, e = 1, extra_column = list(mo = c("months",
  "month", "mon", "m"), yr = c("years", "year", "yrs", "yr", "y"), day =
  c("days", "day", "d")))

Arguments

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

Value

a distance matrix of binary values where 0 indicates that two ages are within the given threshold of each other and 1 indicates not.

Examples

 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"))

Hackout3/epimatch documentation built on May 6, 2019, 9:48 p.m.