Learn R Programming

rtables (version 0.4.0)

insert_row_at_path: Insert Row at Path

Description

Insert a row into an existing table directly before or directly after an existing data (i.e., non-content and non-label) row, specified by its path.

Usage

insert_row_at_path(tt, path, value, after = FALSE)

# S4 method for VTableTree,DataRow insert_row_at_path(tt, path, value, after = FALSE)

# S4 method for VTableTree,ANY insert_row_at_path(tt, path, value)

Arguments

tt

TableTree (or related class). A TableTree object representing a populated table.

path

character. A vector path for a position within the structure of a tabletree. Each element represents a subsequent choice amongst the children of the previous choice.

value

The new value

after

logical(1). Should value be added as a row directly before (FALSE, the default) or after (TRUE) the row specified by path.

See Also

DataRow rrow

Examples

Run this code
# NOT RUN {
lyt <- basic_table() %>%
  split_rows_by("COUNTRY", split_fun = keep_split_levels(c("CHN", "USA"))) %>%
  analyze("AGE")

tab <- build_table(lyt, DM)

tab2 <- insert_row_at_path(tab, c("COUNTRY", "CHN", "AGE", "Mean"),
                          rrow("new row", 555))
tab2
tab2 <- insert_row_at_path(tab2, c("COUNTRY", "CHN", "AGE", "Mean"),
                          rrow("new row redux", 888),
                          after = TRUE)
tab2
# }

Run the code above in your browser using DataLab