# NOT RUN {
DD <- expand.grid(Arm = paste0('Arm ', c(1,2,4)),
Gender = c('Male', 'Female'),
Haircolor = c('Red', 'Green', 'Blue'),
Income = c('Low', 'Med', 'High'), stringsAsFactors = TRUE)
DD <- doBy::orderBy(~ Arm + Gender + Haircolor + Income, DD)
DD$values1 <- runif(dim(DD)[1])
DD$values2 <- 1
DD$values3 <- sample(letters[1:4], size = nrow(DD), replace = TRUE)
keys = c('Arm', 'Gender', 'Haircolor', 'Income')
values = c('values1', 'values2', 'values3')
# }
# NOT RUN {
DDD <- indent_data_frame(DD, keys, indent_character = ' ')
# print both:
Hmisc::latex(DD,
file = '',
longtable = TRUE,
caption = 'Original table',
rowname = NULL)
Hmisc::latex(DDD,
file = '',
longtable = TRUE,
caption = 'Indented table',
rowname = NULL)
# }
Run the code above in your browser using DataLab