Convert a column to header rows

column_to_header(
  ht,
  col,
  ...,
  glue = "{value}",
  start_col = 1,
  ignore_headers = TRUE,
  set_headers = TRUE
)

Arguments

ht

A huxtable.

col

A column specifier for a single column.

...

Properties to set on new rows

glue

Glue string. "{value}" will be replaced by the column value.

start_col

Integer. New header text will start at this column.

ignore_headers

Logical. Ignore existing headers?

set_headers

Logical. Set new rows as headers?

Examples

column_to_header(jams, "Type")
#>                               Price   Sugar content  
#>                             Strawberry               
#>                                1.90          40.00%  
#>                             Raspberry                
#>                                2.10          35.00%  
#>                             Plum                     
#>                                1.80          50.00%  
#> 
#> Column names: Price, Sugar
column_to_header(jams, "Type", text_color = "red")
#>                               Price   Sugar content  
#>                             Strawberry               
#>                                1.90          40.00%  
#>                             Raspberry                
#>                                2.10          35.00%  
#>                             Plum                     
#>                                1.80          50.00%  
#> 
#> Column names: Price, Sugar
column_to_header(jams, "Price",
                   number_format = 2,
                   italic = TRUE,
                   glue = "Price: {value}")
#>                            Type         Sugar content  
#>                            Price: 1.90                 
#>                            Strawberry          40.00%  
#>                            Price: 2.10                 
#>                            Raspberry           35.00%  
#>                            Price: 1.80                 
#>                            Plum                50.00%  
#> 
#> Column names: Type, Sugar

iris_hux <- as_hux(iris[c(1:4, 51:54, 101:104), ])
column_to_header(iris_hux, "Species",
                   markdown = TRUE,
                   glue = "Species: **{value}**"
                 )
#>             Sepal.Length   Sepal.Width   Petal.Length   Petal.Width  
#>             Species: setosa                                          
#>                      5.1           3.5            1.4           0.2  
#>                      4.9           3              1.4           0.2  
#>                      4.7           3.2            1.3           0.2  
#>                      4.6           3.1            1.5           0.2  
#>             Species: versicolor                                      
#>                      7             3.2            4.7           1.4  
#>                      6.4           3.2            4.5           1.5  
#>                      6.9           3.1            4.9           1.5  
#>                      5.5           2.3            4             1.3  
#>             Species: virginica                                       
#>                      6.3           3.3            6             2.5  
#>                      5.8           2.7            5.1           1.9  
#>                      7.1           3              5.9           2.1  
#>                      6.3           2.9            5.6           1.8  
#> 
#> Column names: Sepal.Length, Sepal.Width, Petal.Length, Petal.Width