CreateSpells: 'CreateSpells'

View source: R/CreateSpells.R

CreateSpellsR Documentation

'CreateSpells'

Description

CreateSpells takes as input a dataset with multiple time windows per unit of observation. Multiple categories of time windows may be recorded per unit, and time windows of the same unit may overlap, even within the same category. The purpose of the function is creating a dataset where the time windows of the each person and category are disjoint (a time window which is disjoint form the others is called spell). Additionally, a category '_overall' is added, where time windows are processed regardless of their category. As an option, overlap of pairs of categories are also processed: each pair will be associated to spells where both values are recorded.

Usage

CreateSpells(
  dataset,
  id,
  start_date,
  end_date,
  category = NULL,
  replace_missing_end_date = NULL,
  overlap = F,
  dataset_overlap = "df_overlap",
  only_overlaps = F,
  gap_allowed = 1
)

Arguments

dataset

name of dataset

id

variable containing the identifier of the unit of observation

start_date

variable containing the start date (the date must me ordered as Year Month Day)

end_date

variable containing the end date (the date must me ordered as Year Month Day)

category

(optional) categorical variable

replace_missing_end_date

(optional). When specified, it contains a date to replace end_date when it is missing.

overlap

(optional) default FALSE. If TRUE, overlaps of pairs of categories are processed as well.

dataset_overlap

(optional) if overlap TRUE, the name of the file containing the overlap dataset

only_overlaps

(optional) if only_overlaps TRUE, skip the calculation the spells

gap_allowed

(optional) Allowed gap in days between two observation periods after which they are counted as a different spell


ARS-toscana/CreateSpells documentation built on Nov. 5, 2023, 11:50 a.m.