Learn R Programming

huxtable (version 4.7.1)

add_rows: Insert one matrix into another.

Description

These functions combine two matrix-like objects and return the result.

Usage

add_rows(x, y, after = nrow(x), ...)

add_columns(x, y, after = ncol(x), ...)

Arguments

x

A matrix-like object, e.g. a huxtable

y

Matrix or vector to be inserted into x

after

Row or column after which y is inserted. Can be 0. Can be a row or column name. By default, inserts y after the end of x.

...

Arguments passed to rbind() or cbind()

Value

For add_rows, the result of rbind(x[1:after,], y, x[-(1:after),]. For add_columns the same but with columns. after = 0 and after = nrow(x) or ncol(x) are handled correctly.

Details

For huxtable objects, arguments in ... can include copy_cell_props.

See Also

insert_row() and insert_column(), which insert multiple values into a single row.

Examples

Run this code
# NOT RUN {
ht <- hux("Gooseberry", 2.15)
add_rows(jams, ht)
add_rows(jams, ht, after = 1)

mx <- matrix(
      c("Sugar", "50%", "60%", "40%",
      "Weight (g)", 300, 250, 300),
      4, 2)
add_columns(jams, mx)
# }

Run the code above in your browser using DataLab