first.panel.gap | R Documentation |
Identifies the first occurrence of a gap in observation periods for each unique subject within a panel data structure. A gap is defined as a period where no data were recorded for an expected interval between observations.
first.panel.gap(
dat,
id.name = "id",
t1.name = "t1",
t2.name = "t2",
gap.name = "gap_before",
first.value = 0,
expected.gap.between = 0,
append.to.table = FALSE
)
dat |
A data frame structured as panel data. |
id.name |
The character name of the identifying variable within dat, used to track subjects across multiple rows of data. |
t1.name |
The character name of the time variable within dat representing the start (left endpoint) of observation intervals. |
t2.name |
The character name of the time variable within dat representing the end (right endpoint) of observation intervals. |
gap.name |
A character value for the name of the variable to be used or created that specifies whether a gap is observed before the record. |
first.value |
The numeric value indicating the expected beginning time of the observation period for each subject. |
expected.gap.between |
The numeric value indicating the expected amount of time between the end of one record and the start of the next; the default is zero, assuming continuous observation. |
append.to.table |
A logical value indicating whether the identified first gap times should be appended as a new column to the existing data.frame (TRUE) or returned as a separate data frame (FALSE, default). |
If append.to.table is FALSE, the function returns a data table with the identified first gap time for each subject, keyed by the id.name. Each subject will have a corresponding gap time, indicating the first observed gap in their data. If append.to.table is TRUE, the original data table is returned with a new column appended, containing the first gap times for each subject. This functionality is critical for longitudinal studies where maintaining continuous observation of subjects is necessary, and identifying gaps can highlight data collection issues or subject attrition.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.