library(ards)
library(dplyr)
# Initialize the ARDS
init_ards(studyid = "MTCARS",
tableid = "01", adsns = "mtcars",
population = "all cars",
time = "1973")
# Perform analysis on MPG
# - Add to ARDS from within continuous variable pipeline
mpgdf <- mtcars |>
select(cyl, mpg) |>
group_by(cyl) |>
summarize(n = n(),
mean = mean(mpg),
std = sd(mpg),
min = min(mpg),
max = max(mpg)) |>
add_ards(statvars = c("n", "mean", "std", "min", "max"),
anal_var = "mpg", trtvar = "cyl")
# Perform analysis on GEAR
# - Add to ARDS from within categorical variable pipeline
geardf <- mtcars |>
mutate(denom = n()) |>
select(cyl, gear, denom) |>
group_by(cyl, gear) |>
summarize(cnt = n(),
denom = max(denom)) |>
mutate(pct = cnt / denom * 100) |>
add_ards(statvars = c("cnt", "pct", "denom"),
anal_var = "gear", trtvar = "cyl")
# Get the ARDS
ards <- get_ards()
# Uncomment to view ards
# View(ards)
Run the code above in your browser using DataLab