# create data with a time-variable
x = atable::test_data
set.seed(42)
x = within(x, {time = sample(paste0("time_", 1:5), size=nrow(x), replace = TRUE)})
split_cols = "time"
group_col = "Group2"
# table for a factor with two levels
atable_longitudinal(x,
target_cols = "Split2",
group_col = group_col,
split_cols = split_cols,
add_margins = TRUE)
# table for a factor with three levels
atable_longitudinal(x,
target_cols = "Split1",
group_col = group_col,
split_cols = split_cols,
add_margins = TRUE)
# table for a numeric variable
atable_longitudinal(x,
target_cols = "Numeric",
group_col = group_col,
split_cols = split_cols,
add_margins = TRUE)
# To print the table in Word or with Latex, use
# e.g. \link[Hmisc]{latex} or \link[officer]{body_add_table}.
# No further modification of the table is needed.
# See \code{\link{atable_compact}} for examples.
Run the code above in your browser using DataLab