These methods are called when one argument to cbind/rbind is a huxtable. As well as combining cell contents, they copy table, row, column and/or cell properties into the returned result.

# S3 method for huxtable
cbind(..., deparse.level = 1, copy_cell_props = TRUE)

# S3 method for huxtable
rbind(..., deparse.level = 1, copy_cell_props = TRUE)

Arguments

...

Vectors, matrices, or huxtables.

deparse.level

Unused.

copy_cell_props

Cell properties to copy from neighbours (see below).

Value

A huxtable.

Details

Table properties will be taken from the first argument which is a huxtable. So will row properties (for cbind) and column properties (for rbind).

If some of the inputs are not huxtables, and copy_cell_props isTRUE, then cell properties will be copied to non-huxtables. Objects on the left or above get priority over those on the right or below.

If copy_cell_props is FALSE, cells from non-huxtable objects will get the default properties.

You cannot bind huxtables with data frames, since the R method dispatch will always call the data frame method instead of the huxtable-specific code. For a solution, see add_columns().

Examples


sugar <- c("Sugar", "40%", "35%", "50%")
jams <- set_bold(jams, 1, everywhere)
cbind(jams, sugar)
#>                   Type         Price   Sugar content    Sugar  
#>                   Strawberry    1.90          40.00%   40.00%  
#>                   Raspberry     2.10          35.00%   35.00%  
#>                   Plum          1.80          50.00%   50.00%  
#> 
#> Column names: Type, Price, Sugar,
cbind(jams, sugar,
     copy_cell_props = FALSE)
#>                    Type         Price   Sugar content   Sugar  
#>                    Strawberry    1.90          40.00%   40%    
#>                    Raspberry     2.10          35.00%   35%    
#>                    Plum          1.80          50.00%   50%    
#> 
#> Column names: Type, Price, Sugar,

jams <- set_text_color(jams,
     everywhere, 1, "red")
rbind(jams, c("Damson", 2.30))
#> Error in attr(ht2, a)[r, ] <- attr(ht1, a)[nrow(ht1), ]: number of items to replace is not a multiple of replacement length
rbind(jams, c("Damson", 2.30),
     copy_cell_props = FALSE)
#> Error in names(x) <- value: 'names' attribute [3] must be the same length as the vector [2]