See the align argument to stable(). This function may be called several times to specify column alignment.

st_align(x, ...)

st_center(x, ...)

st_left(x, ...)

st_right(x, ...)

Arguments

x

an stobject.

...

named arguments passed to cols_align().

Value

An updated version of x.

Examples

library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union

ob <- st_new(ptdata())

ob %>% st_align(.default = 'l') %>% stable()
#>  [1] "\\setlength{\\tabcolsep}{5pt} "                                             
#>  [2] "\\begin{threeparttable}"                                                    
#>  [3] "\\renewcommand{\\arraystretch}{1.3}"                                        
#>  [4] "\\begin{tabular}[h]{lllllllll}"                                             
#>  [5] "\\hline"                                                                    
#>  [6] "STUDY & DOSE & FORM & N & WT & CRCL & AGE & ALB & SCR \\\\"                 
#>  [7] "\\hline"                                                                    
#>  [8] "12-DEMO-001 & 100 mg & tablet & 80 & 71.4 & 104 & 33.7 & 4.20 & 1.06 \\\\"  
#>  [9] "12-DEMO-001 & 150 mg & capsule & 16 & 89.4 & 122 & 24.4 & 4.63 & 1.12 \\\\" 
#> [10] "12-DEMO-001 & 150 mg & tablet & 48 & 81.7 & 104 & 34.4 & 3.83 & 0.910 \\\\" 
#> [11] "12-DEMO-001 & 150 mg & troche & 16 & 94.0 & 93.2 & 27.4 & 4.94 & 1.25 \\\\" 
#> [12] "12-DEMO-001 & 200 mg & tablet & 64 & 67.9 & 100 & 27.5 & 4.25 & 1.10 \\\\"  
#> [13] "12-DEMO-001 & 200 mg & troche & 16 & 76.6 & 99.2 & 22.8 & 4.54 & 1.15 \\\\" 
#> [14] "12-DEMO-002 & 100 mg & capsule & 36 & 61.3 & 113 & 38.3 & 4.04 & 1.28 \\\\" 
#> [15] "12-DEMO-002 & 100 mg & tablet & 324 & 77.6 & 106 & 29.9 & 4.31 & 0.981 \\\\"
#> [16] "12-DEMO-002 & 50 mg & capsule & 36 & 74.1 & 112 & 37.1 & 4.44 & 0.900 \\\\" 
#> [17] "12-DEMO-002 & 50 mg & tablet & 324 & 71.2 & 106 & 34.1 & 4.63 & 0.868 \\\\" 
#> [18] "12-DEMO-002 & 75 mg & capsule & 36 & 72.4 & 105 & 38.2 & 3.89 & 0.900 \\\\" 
#> [19] "12-DEMO-002 & 75 mg & tablet & 288 & 71.6 & 98.9 & 34.2 & 4.49 & 0.991 \\\\"
#> [20] "12-DEMO-002 & 75 mg & troche & 36 & 73.6 & 103 & 49.2 & 4.52 & 0.930 \\\\"  
#> [21] "\\hline"                                                                    
#> [22] "\\end{tabular}"                                                             
#> [23] "\\end{threeparttable}"                                                      
#> attr(,"class")
#> [1] "stable"

ob %>% st_center(N = 'l') %>% stable()
#>  [1] "\\setlength{\\tabcolsep}{5pt} "                                             
#>  [2] "\\begin{threeparttable}"                                                    
#>  [3] "\\renewcommand{\\arraystretch}{1.3}"                                        
#>  [4] "\\begin{tabular}[h]{ccclccccc}"                                             
#>  [5] "\\hline"                                                                    
#>  [6] "STUDY & DOSE & FORM & N & WT & CRCL & AGE & ALB & SCR \\\\"                 
#>  [7] "\\hline"                                                                    
#>  [8] "12-DEMO-001 & 100 mg & tablet & 80 & 71.4 & 104 & 33.7 & 4.20 & 1.06 \\\\"  
#>  [9] "12-DEMO-001 & 150 mg & capsule & 16 & 89.4 & 122 & 24.4 & 4.63 & 1.12 \\\\" 
#> [10] "12-DEMO-001 & 150 mg & tablet & 48 & 81.7 & 104 & 34.4 & 3.83 & 0.910 \\\\" 
#> [11] "12-DEMO-001 & 150 mg & troche & 16 & 94.0 & 93.2 & 27.4 & 4.94 & 1.25 \\\\" 
#> [12] "12-DEMO-001 & 200 mg & tablet & 64 & 67.9 & 100 & 27.5 & 4.25 & 1.10 \\\\"  
#> [13] "12-DEMO-001 & 200 mg & troche & 16 & 76.6 & 99.2 & 22.8 & 4.54 & 1.15 \\\\" 
#> [14] "12-DEMO-002 & 100 mg & capsule & 36 & 61.3 & 113 & 38.3 & 4.04 & 1.28 \\\\" 
#> [15] "12-DEMO-002 & 100 mg & tablet & 324 & 77.6 & 106 & 29.9 & 4.31 & 0.981 \\\\"
#> [16] "12-DEMO-002 & 50 mg & capsule & 36 & 74.1 & 112 & 37.1 & 4.44 & 0.900 \\\\" 
#> [17] "12-DEMO-002 & 50 mg & tablet & 324 & 71.2 & 106 & 34.1 & 4.63 & 0.868 \\\\" 
#> [18] "12-DEMO-002 & 75 mg & capsule & 36 & 72.4 & 105 & 38.2 & 3.89 & 0.900 \\\\" 
#> [19] "12-DEMO-002 & 75 mg & tablet & 288 & 71.6 & 98.9 & 34.2 & 4.49 & 0.991 \\\\"
#> [20] "12-DEMO-002 & 75 mg & troche & 36 & 73.6 & 103 & 49.2 & 4.52 & 0.930 \\\\"  
#> [21] "\\hline"                                                                    
#> [22] "\\end{tabular}"                                                             
#> [23] "\\end{threeparttable}"                                                      
#> attr(,"class")
#> [1] "stable"

# This is only to illustrate multiple calls
ob %>%
  st_center(N = 'l') %>%
  st_align(STUDY = col_ragged(2), WT = 'r') %>%
  st_right(N = 'c') %>%
  stable()
#>  [1] "\\setlength{\\tabcolsep}{5pt} "                                             
#>  [2] "\\begin{threeparttable}"                                                    
#>  [3] "\\renewcommand{\\arraystretch}{1.3}"                                        
#>  [4] "\\begin{tabular}[h]{>{\\raggedright\\arraybackslash}p{2cm}rrcrrrrr}"        
#>  [5] "\\hline"                                                                    
#>  [6] "STUDY & DOSE & FORM & N & WT & CRCL & AGE & ALB & SCR \\\\"                 
#>  [7] "\\hline"                                                                    
#>  [8] "12-DEMO-001 & 100 mg & tablet & 80 & 71.4 & 104 & 33.7 & 4.20 & 1.06 \\\\"  
#>  [9] "12-DEMO-001 & 150 mg & capsule & 16 & 89.4 & 122 & 24.4 & 4.63 & 1.12 \\\\" 
#> [10] "12-DEMO-001 & 150 mg & tablet & 48 & 81.7 & 104 & 34.4 & 3.83 & 0.910 \\\\" 
#> [11] "12-DEMO-001 & 150 mg & troche & 16 & 94.0 & 93.2 & 27.4 & 4.94 & 1.25 \\\\" 
#> [12] "12-DEMO-001 & 200 mg & tablet & 64 & 67.9 & 100 & 27.5 & 4.25 & 1.10 \\\\"  
#> [13] "12-DEMO-001 & 200 mg & troche & 16 & 76.6 & 99.2 & 22.8 & 4.54 & 1.15 \\\\" 
#> [14] "12-DEMO-002 & 100 mg & capsule & 36 & 61.3 & 113 & 38.3 & 4.04 & 1.28 \\\\" 
#> [15] "12-DEMO-002 & 100 mg & tablet & 324 & 77.6 & 106 & 29.9 & 4.31 & 0.981 \\\\"
#> [16] "12-DEMO-002 & 50 mg & capsule & 36 & 74.1 & 112 & 37.1 & 4.44 & 0.900 \\\\" 
#> [17] "12-DEMO-002 & 50 mg & tablet & 324 & 71.2 & 106 & 34.1 & 4.63 & 0.868 \\\\" 
#> [18] "12-DEMO-002 & 75 mg & capsule & 36 & 72.4 & 105 & 38.2 & 3.89 & 0.900 \\\\" 
#> [19] "12-DEMO-002 & 75 mg & tablet & 288 & 71.6 & 98.9 & 34.2 & 4.49 & 0.991 \\\\"
#> [20] "12-DEMO-002 & 75 mg & troche & 36 & 73.6 & 103 & 49.2 & 4.52 & 0.930 \\\\"  
#> [21] "\\hline"                                                                    
#> [22] "\\end{tabular}"                                                             
#> [23] "\\end{threeparttable}"                                                      
#> attr(,"class")
#> [1] "stable"