create_courses: Create courses of therapy within data

View source: R/create_courses.R

create_coursesR Documentation

Create courses of therapy within data

Description

Create courses of therapy in CCMH data.

Usage

create_courses(data, firstOnly = FALSE, daysbetween = 90)

Arguments

data

CCMH data files with UniqueClientID and Date variables

firstOnly

If FALSE, will return the whole data set. If TRUE, will return only each client's first course.

daysbetween

The number of days between records that triggers an additional course. By default, 90.

Value

A data frame with added variables indicating courses.

If firstOnly = FALSE, all courses are retained, with the following variables added:

  • UniqueClientID_byCourse: an ID unique to each course of therapy. This is created by adding .1 to UniqueClientID for their first course (e.g. 100.1), .2 for their second course (100.2), etc.

  • RankCourse: The course number that the line of data belongs to, numbered 1 through N of courses.

  • FirstCourse: A dichotomous variable indicating whether the lines of data belong to a client's first course or not.

If firstOnly = TRUE, only the first course is selected, and no variables are added.


CCMH-PSU/CCMHr documentation built on Jan. 31, 2024, 1:08 a.m.