These convenience functions wrap cbind
or rbind
for huxtables, to insert
a single row or column.
insert_column( ht, ..., after = 0, fill = NULL, rowspan = 1, copy_cell_props = TRUE ) insert_row( ht, ..., after = 0, fill = NULL, colspan = 1, copy_cell_props = TRUE )
ht | A huxtable. |
---|---|
... | Cell contents. |
after | Insert the row/column after this position. 0 (the default) inserts as the first row/column. |
fill | String. If |
rowspan, colspan | Scalar integer. Sets the rowspan or colspan of the first cell only.
this. The default |
copy_cell_props | Copy cell properties from the previous row or column (if after > 0). See |
The modified huxtable
In insert_column
only, you can use a column name for after
.
Even if colspan
or rowspan
are greater than 1, you must still provide
values for the hidden cells. Use fill = ""
for this.
add_rows()
and add_columns()
, which insert multiple rows/columns at once.
#> Type Price #> Gooseberry 2.15 #> Strawberry 1.90 #> Raspberry 2.10 #> Plum 1.80 #> #> Column names: Type, Price#> Type Price Sugar #> Strawberry 1.90 50.00% #> Raspberry 2.10 60.00% #> Plum 1.80 40.00% #> #> Column names: Type, Price,insert_column(jams, "Sugar", after = "Price", fill = "50%" )#> Type Price Sugar #> Strawberry 1.90 50.00% #> Raspberry 2.10 50.00% #> Plum 1.80 50.00% #> #> Column names: Type, Price,# don't forget to use `fill`: insert_row(jams, "Jams and prices", fill = "", colspan = 2 )#> Jams and prices #> Type Price #> Strawberry 1.90 #> Raspberry 2.10 #> Plum 1.80 #> #> Column names: Type, Price