Skip to contents

Currently supported cell value alignments. These values may be used to set content alignment (align in rcell() or .aligns in in_rows()).

Usage

rtables_aligns()

Value

a vector of alignments currently supported.

See also

Examples

# See the alignments available in rtables
rtables_aligns()
#> [1] "left"   "right"  "center"

# Right alignment with align in rcell()
lyt <- basic_table() %>%
  analyze("Species", function(x) in_rows(left = rcell("r", align = "right")))

tbl <- build_table(lyt, iris)
tbl
#>        all obs
#> ——————————————
#> left         r

# Set multiple alignments using character vectors with .aligns in in_rows()
lyt2 <- basic_table() %>%
  analyze("Species", function(x) {
    in_rows(
      left = rcell("l"),
      right = rcell("r"),
      .aligns = c("left", "right")
    )
  })

tbl2 <- build_table(lyt2, iris)
tbl2
#>         all obs
#> ———————————————
#> left    l      
#> right         r

# Clinical data example:
lyt3 <- basic_table() %>%
  split_cols_by("ARM") %>%
  split_rows_by("SEX", split_fun = drop_split_levels) %>%
  analyze(c("AGE"), function(x) {
    in_rows(
      "mean" = rcell(mean(x), align = "right"),
      "sd" = rcell(sd(x), align = "left"), .formats = c("xx.x")
    )
  }, show_labels = "visible", na_str = "NE")

tbl3 <- build_table(lyt3, ex_adsl)
tbl3
#>                    A: Drug X   B: Placebo   C: Combination
#> ——————————————————————————————————————————————————————————
#> F                                                         
#>   AGE                                                     
#>     mean                32.8         34.1             35.2
#>     sd             6.1         7.1          7.4           
#> M                                                         
#>   AGE                                                     
#>     mean                35.6         37.4             35.4
#>     sd             7.1         8.7          8.2           
#> U                                                         
#>   AGE                                                     
#>     mean                31.7         31.0             35.2
#>     sd             3.2         5.7          3.1           
#> UNDIFFERENTIATED                                          
#>   AGE                                                     
#>     mean                28.0           NE             45.0
#>     sd             NE          NE           1.4