rpact
Confirmatory Adaptive Clinical Trial Design
Guide users through confirmatory adaptive clinical trial design and analysis using the rpact R package. Use this skill when the user asks about: adaptive designs, sample size reassessment, conditional power, inverse normal combination test, Fisher combination test, multi-stage designs, or rpact design objects.
Adaptive Clinical Trial Design with rpact
Note: This skill targets rpact >= 4.4.0 (CRAN). Dev version 4.4.0.9305 is on GitHub.
API reference
- Full function docs:
references/llms.txt(source: https://docs.rpact.org/reference/) - Workflow patterns:
references/code_patterns.md
Key functions
Trial design
getDesignGroupSequential()- Group sequential design (O’Brien-Fleming, Pocock, alpha-spending, etc.)getDesignInverseNormal()- Inverse normal combination test for adaptive designsgetDesignFisher()- Fisher combination test for adaptive designsgetDesignConditionalDunnett()- Conditional Dunnett test for multi-armgetDesignCharacteristics()- Design characteristics and propertiesgetDesignSet()- Compare multiple designsgetFutilityBounds()- Convert futility bounds between scales (z-value, p-value, conditional power, predictive power, reverse conditional power, effect estimate) (new in 4.3.0)
Sample size
getSampleSizeMeans()- Continuous endpointsgetSampleSizeRates()- Binary endpointsgetSampleSizeSurvival()- Time-to-event endpointsgetSampleSizeCounts()- Count data endpoints
Power
getPowerMeans()- Continuous endpointsgetPowerRates()- Binary endpointsgetPowerSurvival()- Time-to-event endpointsgetPowerCounts()- Count data endpointsgetPowerAndAverageSampleNumber()- Power and ASN
Simulation
getSimulationMeans()/getSimulationRates()/getSimulationSurvival()/getSimulationCounts()- Two-armgetSimulationMultiArmMeans()/getSimulationMultiArmRates()/getSimulationMultiArmSurvival()- Multi-armgetSimulationEnrichmentMeans()/getSimulationEnrichmentRates()/getSimulationEnrichmentSurvival()- Enrichment
Analysis
getDataset()- Enter stage-wise observed datagetStageResults()- Compute stage-wise test statisticsgetAnalysisResults()- Final adaptive analysis resultsgetClosedCombinationTestResults()- Closed testing for multi-armgetClosedConditionalDunnettTestResults()- Dunnett closed testinggetConditionalPower()- Conditional power at interimgetConditionalRejectionProbabilities()- CRP for adaptive recalculation
Inference
getFinalPValue()- Adjusted final p-valuegetFinalConfidenceInterval()- Adjusted confidence intervalgetRepeatedPValues()- Repeated p-values across stagesgetRepeatedConfidenceIntervals()- Repeated CIs across stages
Utilities
getAccrualTime()- Define accrual periodgetPiecewiseSurvivalTime()- Piecewise exponential survivalgetEventProbabilities()- Event probability computationgetNumberOfSubjects()- Expected accrual over timegetObservedInformationRates()- Observed information ratesgetTestActions()- Decision at each stagegetPerformanceScore()- Design performance evaluation
Plotting
plot()methods for all design, power, simulation, and analysis objectsgetAvailablePlotTypes()- List available plot types for an object
I/O
readDataset()/readDatasets()- Read data from CSVwriteDataset()/writeDatasets()- Write data to CSVgetObjectRCode()- Generate reproducible R code for any rpact object
Workflow patterns
For detailed code templates, read references/code_patterns.md.
Topics covered: - Group sequential designs (OF, Pocock, alpha-spending, HSD, custom futility) - Adaptive designs (inverse normal combination, Fisher combination) - Sample size for survival (HR, medians, event probabilities, piecewise) - Sample size for means and rates (one-sample, two-sample, risk ratio) - Power computation (survival, means, rates) - Simulation for survival (two-arm, piecewise/NPH, multiple scenarios) - Multi-arm designs and simulation (Dunnett, arm selection, dose-response) - Enrichment designs (subgroup-specific effects) - Entering observed data with getDataset() (survival, means, rates) - Stage results and analysis (getStageResults(), getAnalysisResults(), getTestActions()) - Conditional power and sample size reassessment - Adjusted inference (final p-values, CIs, repeated p-values/CIs) - Piecewise survival and accrual specification - Comparing designs with getDesignSet() - Plotting (boundaries, power curves, simulation results) - Reproducible code with getObjectRCode()
Important design considerations
typeOfDesignchoices: “OF” (O’Brien-Fleming), “P” (Pocock), “asOF”/“asHSD”/“asKD” (alpha-spending variants). Alpha-spending versions (“as*“) allow unequal information rate spacinggetDesignInverseNormal()vsgetDesignGroupSequential(): Same signature, but inverse normal is for adaptive designs where sample size can be recalculated between stagesbindingFutility = FALSE: Non-binding futility is standard for confirmatory trials; efficacy bounds computed ignoring futility- Survival parameterization: Can specify treatment effect via
hazardRatio,median1/median2,lambda1/lambda2, orpi1/pi2(event probabilities) — use only one plannedEventsin simulation: Vector of cumulative event counts at each analysis (not information fractions)- Multi-arm
intersectionTest: “Dunnett” (parametric, most powerful), “Simes” (non-parametric), “Bonferroni” (conservative) typeOfSelection: Controls arm selection at interim — “best” (highest effect), “rBest” (r best arms), “epsilon” (within epsilon of best), “all” (no dropping)getObjectRCode(): Use to generate reproducible R code for any rpact object — invaluable for reporting and validationfutilityBoundsScale(v4.3.0+): IngetDesignInverseNormal()andgetDesignGroupSequential(), specify futility bounds on alternative scales (p-value, conditional power, etc.) that are internally convertedalpha0Scale(v4.3.0+): IngetDesignFisher(), specify alpha0 bounds on alternative scalesefficacyStops/futilityStops(v4.2.1+): Control which stages have efficacy/futility stopping- Dose-response (v4.2.0+): Multi-arm simulations support
doseLevelsfor linear or sigmoid Emax models - Unequal variances (v4.2.0+):
getSampleSizeMeans(),getPowerMeans(),getSimulationMeans()support different variances per group - rpact defaults:
alpha = 0.05,beta = 0.2,kMax = NA(inferred),sided = 1— always set explicitly for clinical trial designs
Code Patterns
Code Patterns for rpact
Note: These patterns target rpact >= 4.x (CRAN). See https://docs.rpact.org for full documentation.
Table of Contents
- Group sequential designs
- Adaptive designs (inverse normal and Fisher)
- Sample size for survival endpoints
- Sample size for means and rates
- Power computation
- Simulation for survival
- Multi-arm designs and simulation
- Enrichment designs
- Entering observed data with getDataset
- Stage results and analysis
- Conditional power and sample size reassessment
- Adjusted inference (p-values and CIs)
- Piecewise survival and accrual specification
- Comparing designs with getDesignSet
- Plotting
- Reproducible code with getObjectRCode
Group sequential designs
getDesignGroupSequential() creates classical group sequential designs with spending functions or fixed boundary types.
O’Brien-Fleming design (default)
library(rpact)
design <- getDesignGroupSequential(
kMax = 3,
alpha = 0.025,
beta = 0.2,
sided = 1,
typeOfDesign = "OF"
)
designPocock design
design <- getDesignGroupSequential(
kMax = 3,
alpha = 0.025,
beta = 0.2,
sided = 1,
typeOfDesign = "P"
)Alpha-spending (Lan-DeMets O’Brien-Fleming)
design <- getDesignGroupSequential(
kMax = 3,
alpha = 0.025,
beta = 0.2,
sided = 1,
informationRates = c(0.5, 0.75, 1),
typeOfDesign = "asOF" # Alpha-spending OF approximation
)Alpha-spending with Hwang-Shih-DeCani (gamma)
design <- getDesignGroupSequential(
kMax = 3,
alpha = 0.025,
sided = 1,
informationRates = c(0.5, 0.75, 1),
typeOfDesign = "asHSD",
gammaA = -4 # Gamma parameter (negative = conservative early)
)Non-binding futility with beta-spending
design <- getDesignGroupSequential(
kMax = 3,
alpha = 0.025,
beta = 0.2,
sided = 1,
informationRates = c(0.5, 0.75, 1),
typeOfDesign = "asOF",
typeBetaSpending = "bsOF", # Beta-spending for futility
bindingFutility = FALSE
)Custom futility bounds
design <- getDesignGroupSequential(
kMax = 3,
alpha = 0.025,
beta = 0.2,
sided = 1,
informationRates = c(0.5, 0.75, 1),
typeOfDesign = "asOF",
futilityBounds = c(0, 0.5), # Z-scale futility bounds at IA1, IA2
bindingFutility = FALSE
)Design characteristics
# Examine properties of any design
chars <- getDesignCharacteristics(design)
chars # Shows power, ASN, stopping probabilitiesAdaptive designs (inverse normal and Fisher)
Inverse normal combination test
# For adaptive designs where sample size can be recalculated mid-trial
design_in <- getDesignInverseNormal(
kMax = 2,
alpha = 0.025,
beta = 0.2,
sided = 1,
typeOfDesign = "asOF"
)Fisher combination test
design_fisher <- getDesignFisher(
kMax = 2,
alpha = 0.025,
method = "equalAlpha", # Equal alpha at each stage
alpha0Vec = 0.5 # Futility bound (p-value scale)
)Fisher with no interaction method
design_fisher <- getDesignFisher(
kMax = 3,
alpha = 0.025,
method = "noInteraction",
alpha0Vec = c(0.5, 0.5)
)Sample size for survival endpoints
Basic survival design (hazard ratio)
design <- getDesignGroupSequential(
kMax = 3, alpha = 0.025, sided = 1,
typeOfDesign = "asOF"
)
ss <- getSampleSizeSurvival(
design = design,
hazardRatio = 0.7,
accrualTime = c(0, 12),
accrualIntensity = 30, # 30 patients/month
followUpTime = 12,
dropoutRate1 = 0.025,
dropoutRate2 = 0.025
)
ssUsing median survival times
ss <- getSampleSizeSurvival(
design = design,
median1 = 18, # Experimental arm median
median2 = 12, # Control arm median
accrualTime = c(0, 6, 12),
accrualIntensity = c(15, 30),
followUpTime = 18,
dropoutRate1 = 0.025,
dropoutRate2 = 0.025
)Using event probabilities
ss <- getSampleSizeSurvival(
design = design,
pi1 = 0.35, # 12-month event rate, experimental
pi2 = 0.50, # 12-month event rate, control
eventTime = 12, # Reference time for pi1, pi2
accrualTime = c(0, 12),
accrualIntensity = 30,
followUpTime = 12
)Piecewise exponential survival
ss <- getSampleSizeSurvival(
design = design,
piecewiseSurvivalTime = c(0, 6),
lambda2 = c(0.04, 0.03), # Control hazard rates per period
hazardRatio = 0.7,
accrualTime = c(0, 12),
accrualIntensity = 30,
followUpTime = 18
)Fixed design (no interim)
ss_fixed <- getSampleSizeSurvival(
hazardRatio = 0.7,
accrualTime = c(0, 12),
accrualIntensity = 30,
followUpTime = 12
)Sample size for means and rates
Continuous endpoint (two-sample)
design <- getDesignGroupSequential(
kMax = 2, alpha = 0.025, sided = 1,
typeOfDesign = "asOF"
)
ss_means <- getSampleSizeMeans(
design = design,
groups = 2,
alternative = 0.5, # Mean difference
stDev = 1,
normalApproximation = TRUE
)
ss_meansOne-sample mean
ss_one <- getSampleSizeMeans(
design = design,
groups = 1,
alternative = 0.3,
stDev = 1
)Binary endpoint (two-sample)
ss_rates <- getSampleSizeRates(
design = design,
groups = 2,
pi1 = 0.40, # Experimental response rate
pi2 = 0.20, # Control response rate
normalApproximation = TRUE
)
ss_ratesBinary endpoint with risk ratio
ss_rr <- getSampleSizeRates(
design = design,
groups = 2,
riskRatio = TRUE,
thetaH0 = 1, # H0: RR = 1
pi1 = 0.40,
pi2 = 0.20
)Power computation
Power for survival endpoint
design <- getDesignGroupSequential(
kMax = 3, alpha = 0.025, sided = 1,
typeOfDesign = "asOF"
)
pwr <- getPowerSurvival(
design = design,
hazardRatio = c(0.6, 0.7, 0.8), # Multiple HR values
maxNumberOfEvents = 300,
maxNumberOfSubjects = 500,
accrualTime = c(0, 12),
accrualIntensity = 42,
followUpTime = 12
)
pwrPower for means
pwr_means <- getPowerMeans(
design = design,
alternative = seq(0.2, 0.8, 0.1),
stDev = 1,
maxNumberOfSubjects = 200
)Power for rates
pwr_rates <- getPowerRates(
design = design,
pi1 = seq(0.3, 0.6, 0.05),
pi2 = 0.2,
maxNumberOfSubjects = 200
)Simulation for survival
Two-arm survival simulation
design <- getDesignGroupSequential(
kMax = 3, alpha = 0.025, sided = 1,
typeOfDesign = "asOF",
typeBetaSpending = "bsOF",
bindingFutility = FALSE
)
sim <- getSimulationSurvival(
design = design,
hazardRatio = 0.7,
plannedEvents = c(100, 200, 300),
maxNumberOfSubjects = 500,
accrualTime = c(0, 12),
accrualIntensity = 42,
followUpTime = 18,
maxNumberOfIterations = 10000,
seed = 12345
)
sim
summary(sim)Simulation under multiple scenarios
sim <- getSimulationSurvival(
design = design,
hazardRatio = c(0.6, 0.7, 0.8, 1.0), # Multiple HR values
plannedEvents = c(100, 200, 300),
maxNumberOfSubjects = 500,
accrualTime = c(0, 12),
accrualIntensity = 42,
followUpTime = 18,
maxNumberOfIterations = 10000,
seed = 12345
)Simulation with piecewise survival (delayed effect)
sim_nph <- getSimulationSurvival(
design = design,
piecewiseSurvivalTime = c(0, 6),
lambda2 = c(0.04, 0.03),
lambda1 = c(0.04, 0.03 * 0.6), # HR = 1 early, 0.6 after 6 months
plannedEvents = c(100, 200, 300),
maxNumberOfSubjects = 500,
accrualTime = c(0, 12),
accrualIntensity = 42,
maxNumberOfIterations = 10000,
seed = 12345
)Multi-arm designs and simulation
Multi-arm survival simulation (Dunnett)
design_in <- getDesignInverseNormal(
kMax = 2,
alpha = 0.025,
sided = 1,
typeOfDesign = "asOF"
)
sim_ma <- getSimulationMultiArmSurvival(
design = design_in,
activeArms = 3,
plannedEvents = c(50, 100),
intersectionTest = "Dunnett",
typeOfSelection = "best", # Select best arm at interim
effectMeasure = "effectEstimate",
successCriterion = "atLeastOne",
hazardRatio = c(0.6, 0.7, 0.8), # HR for each active arm
maxNumberOfSubjects = 400,
accrualTime = c(0, 12),
accrualIntensity = 40,
maxNumberOfIterations = 10000,
seed = 12345
)
sim_maMulti-arm with dose-response (means)
sim_dose <- getSimulationMultiArmMeans(
design = design_in,
activeArms = 4,
typeOfShape = "sigmoidEmax",
muMaxVector = seq(0.2, 1, 0.2), # Maximum effect sizes
gED50 = 2,
intersectionTest = "Dunnett",
typeOfSelection = "best",
stDev = 1,
maxNumberOfSubjects = 300,
maxNumberOfIterations = 10000
)Multi-arm with arm dropping
sim_drop <- getSimulationMultiArmSurvival(
design = design_in,
activeArms = 3,
plannedEvents = c(50, 100),
intersectionTest = "Simes",
typeOfSelection = "epsilon", # Drop if within epsilon of best
epsilonValue = 0.1,
hazardRatio = c(0.6, 0.7, 0.8),
maxNumberOfSubjects = 400,
accrualTime = c(0, 12),
accrualIntensity = 40,
maxNumberOfIterations = 10000
)Enrichment designs
Enrichment survival simulation
design_in <- getDesignInverseNormal(
kMax = 2,
alpha = 0.025,
sided = 1,
typeOfDesign = "asOF"
)
# Effect sizes: rows = scenarios, columns = populations (S, F\S)
effectList <- list(
subGroups = c("S", "R"), # Subgroup and complement
prevalences = c(0.4, 0.6),
effects = matrix(c(
0.7, 1.0, # Scenario 1: effect only in subgroup
0.7, 0.8, # Scenario 2: larger effect in subgroup
0.7, 0.7 # Scenario 3: equal effect
), ncol = 2, byrow = TRUE)
)
sim_enrich <- getSimulationEnrichmentSurvival(
design = design_in,
effectList = effectList,
intersectionTest = "Simes",
typeOfSelection = "best",
successCriterion = "atLeastOne",
plannedEvents = c(80, 160),
maxNumberOfSubjects = 400,
maxNumberOfIterations = 10000,
seed = 12345
)Entering observed data with getDataset
Survival data (cumulative events and logrank statistics)
# Stage-wise observed data
data_surv <- getDataset(
cumulativeEvents = c(50, 100, 150),
cumulativeLogRanks = c(1.2, 1.8, 2.3)
)Means data (two-arm)
data_means <- getDataset(
n1 = c(30, 30), # Stage-wise sample sizes, arm 1
n2 = c(30, 30), # Stage-wise sample sizes, arm 2
means1 = c(1.5, 1.8), # Stage-wise means, arm 1
means2 = c(1.0, 1.1), # Stage-wise means, arm 2
stDevs1 = c(2.0, 2.1), # Stage-wise SDs, arm 1
stDevs2 = c(1.9, 2.0) # Stage-wise SDs, arm 2
)Rates data (two-arm)
data_rates <- getDataset(
n1 = c(50, 50),
n2 = c(50, 50),
events1 = c(20, 25),
events2 = c(10, 15)
)Reading from CSV
data_csv <- readDataset("trial_data.csv")Stage results and analysis
Computing stage results
design <- getDesignGroupSequential(
kMax = 3, alpha = 0.025, sided = 1,
typeOfDesign = "asOF"
)
data <- getDataset(
cumulativeEvents = c(50, 100),
cumulativeLogRanks = c(1.5, 2.1)
)
stageResults <- getStageResults(design, data)
stageResultsFull analysis results
results <- getAnalysisResults(
design = design,
dataInput = data,
directionUpper = FALSE # Lower is better (HR < 1)
)
resultsChecking test actions
# What decision at each stage?
getTestActions(results)
# Returns: "continue", "reject", or "accept" (futility)Conditional power and sample size reassessment
Conditional power at interim
design <- getDesignInverseNormal(
kMax = 2, alpha = 0.025, sided = 1,
typeOfDesign = "asOF"
)
data <- getDataset(
n1 = c(50),
n2 = c(50),
means1 = c(1.5),
means2 = c(1.0),
stDevs1 = c(2.0),
stDevs2 = c(1.9)
)
stageResults <- getStageResults(design, data)
# Conditional power for planned n
cp <- getConditionalPower(
stageResults,
nPlanned = c(100) # Planned total n for stage 2
)
cpConditional rejection probabilities (for SSR)
crp <- getConditionalRejectionProbabilities(stageResults)
crp
# Sample size reassessment: increase stage 2 n to achieve target CP
# Use conditional power to determine new nAdjusted inference (p-values and CIs)
Final p-value
design <- getDesignGroupSequential(
kMax = 3, alpha = 0.025, sided = 1,
typeOfDesign = "asOF"
)
data <- getDataset(
n1 = c(30, 30, 30),
n2 = c(30, 30, 30),
means1 = c(1.5, 1.8, 2.0),
means2 = c(1.0, 1.1, 1.0),
stDevs1 = c(2.0, 2.1, 1.9),
stDevs2 = c(1.9, 2.0, 2.0)
)
stageResults <- getStageResults(design, data)
# Stage-wise adjusted p-value
pval <- getFinalPValue(stageResults)
pvalFinal confidence interval
ci <- getFinalConfidenceInterval(
design = design,
dataInput = data,
directionUpper = TRUE
)
ciRepeated p-values and confidence intervals
results <- getAnalysisResults(design, data, directionUpper = TRUE)
# Repeated p-values (available at each stage)
results$repeatedPValues
# Repeated CIs
results$repeatedConfidenceIntervalLowerBounds
results$repeatedConfidenceIntervalUpperBoundsPiecewise survival and accrual specification
Accrual time with ramp-up
# Vector specification
accrual <- getAccrualTime(
accrualTime = c(0, 3, 6, 12),
accrualIntensity = c(10, 20, 30), # Patients/month per period
maxNumberOfSubjects = 500
)
# List specification (more readable)
accrual <- getAccrualTime(
list(
"0 - <3" = 10,
"3 - <6" = 20,
"6 - 12" = 30
),
maxNumberOfSubjects = 500
)Piecewise exponential survival
# Delayed treatment effect
pw_surv <- getPiecewiseSurvivalTime(
piecewiseSurvivalTime = c(0, 6),
lambda2 = c(0.04, 0.03), # Control hazard
lambda1 = c(0.04, 0.03 * 0.6) # Experimental hazard (HR = 1, then 0.6)
)
# Using hazard ratio (applied to all periods)
pw_surv <- getPiecewiseSurvivalTime(
piecewiseSurvivalTime = c(0, 6),
lambda2 = c(0.04, 0.03),
hazardRatio = 0.7
)
# List specification
pw_surv <- getPiecewiseSurvivalTime(
list(
"0 - <6" = 0.04,
">=6" = 0.03
),
hazardRatio = 0.7
)Using piecewise objects in sample size
ss <- getSampleSizeSurvival(
design = getDesignGroupSequential(kMax = 3, alpha = 0.025, typeOfDesign = "asOF"),
piecewiseSurvivalTime = c(0, 6),
lambda2 = c(0.04, 0.03),
hazardRatio = 0.7,
accrualTime = c(0, 3, 6, 12),
accrualIntensity = c(10, 20, 30),
followUpTime = 18
)Comparing designs with getDesignSet
Varying a single parameter
# Compare O'Brien-Fleming, Pocock, and HSD designs
ds <- getDesignSet(
design = getDesignGroupSequential(kMax = 3, alpha = 0.025, sided = 1),
typeOfDesign = c("OF", "P", "asHSD")
)
plot(ds)Comparing gamma values
ds <- getDesignSet(
design = getDesignGroupSequential(
kMax = 3, alpha = 0.025, sided = 1,
typeOfDesign = "asHSD"
),
gammaA = c(-4, -2, 0, 2)
)
plot(ds)From pre-built designs
d1 <- getDesignGroupSequential(kMax = 3, alpha = 0.025, typeOfDesign = "OF")
d2 <- getDesignGroupSequential(kMax = 3, alpha = 0.025, typeOfDesign = "P")
d3 <- getDesignGroupSequential(kMax = 3, alpha = 0.025, typeOfDesign = "asOF")
ds <- getDesignSet(designs = c(d1, d2, d3))
plot(ds)Plotting
Design boundaries
design <- getDesignGroupSequential(
kMax = 4, alpha = 0.025, sided = 1,
typeOfDesign = "asOF",
typeBetaSpending = "bsOF",
bindingFutility = FALSE
)
# Default: boundary plot
plot(design)
# Specific plot type
plot(design, type = 1) # Boundaries (Z-scale)
plot(design, type = 3) # Stage levels (adjusted significance levels)
plot(design, type = 4) # Error spending
plot(design, type = 5) # Power and early stoppingSample size results
ss <- getSampleSizeSurvival(
design = design,
hazardRatio = seq(0.5, 0.9, 0.05),
accrualTime = c(0, 12),
accrualIntensity = 30,
followUpTime = 12
)
plot(ss)Power curves
pwr <- getPowerSurvival(
design = design,
hazardRatio = seq(0.5, 1, 0.05),
maxNumberOfEvents = 300,
maxNumberOfSubjects = 500,
accrualTime = c(0, 12),
accrualIntensity = 42,
followUpTime = 12
)
plot(pwr)Simulation results
sim <- getSimulationSurvival(
design = design,
hazardRatio = c(0.6, 0.7, 0.8, 1.0),
plannedEvents = c(75, 150, 225, 300),
maxNumberOfSubjects = 500,
accrualTime = c(0, 12),
accrualIntensity = 42,
maxNumberOfIterations = 10000
)
plot(sim)Available plot types
# Check what plot types are available for any object
getAvailablePlotTypes(design)
getAvailablePlotTypes(ss)Reproducible code with getObjectRCode
design <- getDesignGroupSequential(
kMax = 3, alpha = 0.025, sided = 1,
typeOfDesign = "asOF"
)
# Print reproducible R code
getObjectRCode(design, output = "cat")
# Include default parameters too
getObjectRCode(design, includeDefaultParameters = TRUE, output = "cat")
# Get as character vector
code <- getObjectRCode(design, output = "vector")
# Markdown output (for reports)
getObjectRCode(design, output = "markdown")