# lulab.utils

    library(lulab.utils)

# Introduction

This package provides a set of utility functions that are commonly used in the ‘LuLab’.

## Data checks

    data("melanoma", package = "boot")
    check_cha("status", melanoma)
    #> .
    #>    1    2    3
    #> 0.28 0.65 0.07

## Numeric rounding

    round2(c(1.25, -1.25), digits = 1)
    #> [1]  1.3 -1.3

## Table 1

`Table1()` creates a stratified summary table and writes `Table1.xlsx` to the specified directory.

    melanoma2 <- melanoma
    melanoma2$status <- factor(
      melanoma2$status,
      levels = c(2, 1, 3),
      labels = c("Alive", "Melanoma death", "Non-melanoma death")
    )

    head(Table1(
      df = melanoma2,
      ycol = "status",
      xcol = c("time", "age", "sex"),
      result_dir = tempdir(),
      verbose = FALSE
    ))
    #>                                          Alive            Melanoma death
    #> 1              time
    #> 2   Median (Q1, Q3) 2374.00 (1858.00, 3329.50) 1062.00 (718.00, 1667.00)
    #> 3       Mean +/- SD           2620.67 ± 948.14          1252.95 ± 759.00
    #> 4               age
    #> 5       Mean +/- SD              50.01 ± 15.92             55.09 ± 17.91
    #> 6   Median (Q1, Q3)       52.00 (40.00, 61.75)      56.00 (44.00, 68.00)
    #>          Non-melanoma death                      Total P-value
    #> 1                                                       <0.001
    #> 2         1338.29 ± 1247.81 2005.00 (1525.00, 3042.00)
    #> 3 1126.50 (262.75, 2028.75)          2152.80 ± 1122.06
    #> 4                                                        0.005
    #> 5             65.29 ± 10.90              52.46 ± 16.67
    #> 6      65.00 (57.00, 71.75)       54.00 (42.00, 65.00)