Combine tinytable objects by rows (vertically)

Description

Combine tinytable objects by rows (vertically)

Usage

## S4 method for signature 'tinytable,tinytable'
rbind2(x, y, use_names = TRUE, headers = TRUE, ...)

Arguments

x tinytable object
y tinytable object
use_names ‘TRUE’ binds by matching column name, ‘FALSE’ by position
headers Logical. TRUE inserts the colnames of y as an extra row between the two tables.
Additional arguments are ignored.

Details

format_tt() calls applied to x or y are evaluated before binding, to allow distinct formatting for each panel.

Calls to other tinytable functions such as style_tt() or group_tt() are ignored when applied to x or y. These functions should be applied to the final table instead.

Information in these S4 slots is carried over from x to the combined table:

  • x@output

  • x@caption

  • x@width

Information in these S4 slots is concatenated and carried over to the combined table:

  • c(x@notes, y@notes)

This function relies on the rbindlist() function from the data.table package.

Examples

library("tinytable")

library(tinytable)
x = tt(mtcars[1:3, 1:2], caption = "Combine two tiny tables.")
y = tt(mtcars[4:5, 8:10]) 

# rbind() does not support additional aarguments
# rbind2() supports additional arguments

# basic combination
rbind(x, y)
Combine two tiny tables.
mpg cyl vs am gear
21.0 6 NA NA NA
21.0 6 NA NA NA
22.8 4 NA NA NA
NA NA vs am gear
NA NA 1 0 3
NA NA 0 0 3
rbind(x, y) |> format_tt(replace = "")
Combine two tiny tables.
mpg cyl vs am gear
21.0 6
21.0 6
22.8 4
vs am gear
1 0 3
0 0 3
# omit y header
rbind2(x, y, headers = FALSE)
Combine two tiny tables.
mpg cyl vs am gear
21.0 6 NA NA NA
21.0 6 NA NA NA
22.8 4 NA NA NA
NA NA 1 0 3
NA NA 0 0 3
# bind by position rather than column names
rbind2(x, y, use_names = FALSE)
Combine two tiny tables.
mpg cyl gear
21.0 6 NA
21.0 6 NA
22.8 4 NA
vs am gear
1 0 3
0 0 3