UniqueMeasurement: UniqueMeasurement

View source: R/UniqueMeasurement.R

UniqueMeasurementR Documentation

UniqueMeasurement

Description

Of the repeated measurements of an individual in the same census year, keep only the measurements (rows) taken at the highest POM (KeepMeas = "MaxHOM"), and/or the most recent measurement (same year but more recent date) (KeepMeas = "MaxDate")

Usage

UniqueMeasurement(Data, KeepMeas = c("MaxHOM", "MaxDate"), ID = "IdStem")

Arguments

Data

Dataset (data.table)

KeepMeas

In case of multiple measurements in the same census year: Possible values: "MaxHOM", "MaxDate" (character).

  • "MaxHOM": keep the measurement taken at the highest HOM/POM

  • "MaxDate": keep the most recent measurement (same year but more recent date)

ID

Column name indicating the identifier of the individual (character)

Value

Dataset (data.table) with 1 measurement (1 row) per Year.

Examples


library(data.table)

Data <- data.table( # 7 rows
IdStem = c(rep("a", 4), rep("b", 2), "c"),
Year = c(rep(2000, 3), 2001, rep(2000, 3)),
Date = as.Date(c("2000-01-10", "2000-01-20", "2000-01-30", "2001-01-10",
                 rep("2000-01-10", 3))),
HOM = c(rep(1, 3), 2, 1, 2, 1)
)
Data

UniqueMeasurement(TestData)


VincyaneBadouard/TreeData documentation built on Jan. 4, 2024, 2:56 a.m.