# Load all required R packages, no changes needed.
library(metalite)
library(kmcurvely)
library(dplyr)
library(tidyr)
library(haven)
# Create analysis plan for interactive Kaplan-Meier plots
plan <- plan(
analysis = "km_curvely",
population = "apat",
observation = "wk12",
parameter = "ttde;male"
)
# Create a metadata representation for ADaM data analysis
# For a typical time-to-event (TTE) analyses: TTE records in observation (adtte), population info in population dataset (adsl).
# Assumes adtte and adsl datasets are already loaded and prepared
adsl <- kmcurvely_adtte
adtte <- kmcurvely_adtte
meta <- meta_adam(observation = adtte, population = adsl)
# Use the analysis plan created in meta-planning section
# Define analysis plan meta information for ADaM dataset
meta <- meta |> define_plan(plan)
# Define analysis meta information using user inputs from Shiny app
meta <- meta |>
# Define population meta information
define_population(
name = "apat",
var = c("USUBJID", "SAFFL", "TRTP", "SITEID", "SEX", "RACE", "AGE"),
group = "TRTP",
subset = SAFFL == 'Y',
label = "All Participants as Treated"
) |>
# Define observation meta information
define_observation(
name = "wk12",
var = c("USUBJID", "SAFFL", "TRTP", "SEX", "PARAM", "PARAMCD", "AVAL", "CNSR"),
group = "TRTP",
subset = SAFFL == 'Y',
label = "Weeks 0 to 12"
) |>
# Define parameter for interactive Kaplan-Meier plots
define_parameter(
name = "ttde",
subset = PARAMCD == "TTDE",
label = "Time to First Dermatologic Event"
) |>
define_parameter(
name = "male",
subset = SEX == "M",
label = "Male"
) |>
# Define analysis meta information for interactive Kaplan-Meier plots.
define_analysis(
name = "km_curvely",
title = "KM Plots of All Participants and Subgroups"
)
# Build complete meta information for interactive Kaplan-Meier plots
meta <- meta |> meta_build()
# Generate Interactive Kaplan-Meier Plots
meta |>
kmcurvely(
population = "apat",
observation = "wk12",
endpoint = "ttde",
subgroup = "male;female",
x_label = NULL,
y_label = "Survival rate",
color = NULL,
time_unit = "months"
)
The error message is below. Please fix it.
Error in `filter()`:
ℹ In argument: `NULL`.
Caused by error:
! `..2` must be of size 254 or 1, not size 0.
The following code indicate an error in
kmcurvely()function.The error message is below. Please fix it.