dropplot | R Documentation |
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.
dropplot(data, id_col, time_col, bins = 100, percentile = 90)
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). |
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.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.