| add_rows {huxtable} | R Documentation |
These functions combine two matrix-like objects and return the result.
add_rows(x, y, after = nrow(x), ...) add_columns(x, y, after = ncol(x), ...)
x |
A matrix-like object, e.g. a huxtable |
y |
Matrix or vector to be inserted into |
after |
Row or column after which |
... |
For huxtable objects, arguments in ... can include copy_cell_props.
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.
insert_row() and insert_column(), which insert multiple values into a single row.
ht <- hux(Jam = c('Blackberry', 'Strawberry'), Price = c(1.90, 1.80), add_colnames = TRUE)
ht2 <- hux('Gooseberry', 2.10)
add_rows(ht, ht2)
add_rows(ht, ht2, after = 1)
mx <- matrix(c('Sugar', '50%', '60%', 'Weight (g)', 300, 250), 3, 2)
add_columns(ht, mx, after = 'Jam')
ht <- hux(a = 1:3, b = 1:3)
ht2 <- hux(d = letters[1:3])
add_columns(ht, ht2, after = "a")