dropplot: Dropout Curve and Observation Distribution for Irregular...

View source: R/dropplot.R

dropplotR Documentation

Dropout Curve and Observation Distribution for Irregular Longitudinal Data

Description

This function generates a combined plot of a dropout curve and a histogram of observation counts over time. The dropout curve shows how many subjects remain in the study over time based on their last observation time. The histogram shows how the observations are distributed across time.

Usage

dropplot(data, id_col, time_col, bins = 100, percentile = 90)

Arguments

data

A data frame containing the longitudinal data.

id_col

A character string specifying the column name for subject identifiers.

time_col

A character string specifying the column name for the time variable.

bins

Number of bins for the histogram (default is 100).

percentile

A numeric value between 0 and 100 specifying the cutoff for the red dropout line (default is 90).

Value

A list with two elements:

  • plot: A ggplot object showing the dropout curve and histogram.

  • data: A data frame with mid-points of the time bins ('mid_time') and the number of observations ('count') in descending order.

Examples

## Not run: 
  data(smocc)  # assumes smocc is loaded with columns id and age
  result <- dropplot(data = smocc, id_col = "id", time_col = "age", bins = 60, percentile = 90)
  print(result$plot)
  head(result$data)

## End(Not run)


ILRCM documentation built on Aug. 12, 2025, 1:08 a.m.

Related to dropplot in ILRCM...