| Title: | Supporting Functions Maintained by Zhen Lu |
|---|---|
| Description: | Miscellaneous functions commonly used by LuLab. This package aims to help more researchers on epidemiology to perform data management and visualization more efficiently. |
| Authors: | Zhen Lu [aut, cre] |
| Maintainer: | Zhen Lu <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.2 |
| Built: | 2026-06-08 13:01:10 UTC |
| Source: | https://github.com/Leslie-Lu/lulab.utils |
Check for missing values for character columns
check_cha(col, df, verbose = TRUE)check_cha(col, df, verbose = TRUE)
col |
a character variable name |
df |
a data.frame |
verbose |
logical, controlling the output |
This function is used to check the distribution of character variables in the data frame.
a distribution table of the character variable in the data frame
Zhen Lu
data("melanoma", package = "boot") melanoma2 <- melanoma check_cha('status', melanoma2) # or mapply(check_cha,'status', MoreArgs= list(melanoma2))data("melanoma", package = "boot") melanoma2 <- melanoma check_cha('status', melanoma2) # or mapply(check_cha,'status', MoreArgs= list(melanoma2))
Check if wget is installed
check_wget()check_wget()
This function is used to check if wget is installed on the system.
a logical value indicating whether wget is installed
Zhen Lu
check_wget()check_wget()
Extract results from a fitted model.
extract_logistic_model( model, markers_name, n_independent_metabolites, digits, effective_size, case_size, control_size, outcome_name )extract_logistic_model( model, markers_name, n_independent_metabolites, digits, effective_size, case_size, control_size, outcome_name )
model |
The fitted logistic model object. |
markers_name |
A character vector of marker names. |
n_independent_metabolites |
The number of independent metabolites. |
digits |
The number of decimal places to round to. |
effective_size |
A numeric vector containing effective sample sizes. |
case_size |
The number of cases. |
control_size |
The number of controls. |
outcome_name |
The name of the outcome variable. |
This function extracts relevant results from a fitted logistic model and formats them for reporting.
A named vector containing the extracted results.
Round a number to a specified number of decimal places.
round2(x, digits = 0)round2(x, digits = 0)
x |
The numeric input to be rounded. |
digits |
The number of decimal places to round to, Default: digits |
This function rounds the input number to the specified number of decimal places.
The rounded numeric value.
Create a stratified Table 1, save it as an Excel workbook, and return the table as a data frame.
Table1(df, ycol, xcol, xlabels = NULL, result_dir, verbose = TRUE)Table1(df, ycol, xcol, xlabels = NULL, result_dir, verbose = TRUE)
df |
A data frame. |
ycol |
A single character string naming the grouping variable. |
xcol |
A character vector naming variables to summarize. |
xlabels |
Optional labels for the groups. Defaults to the observed
levels of |
result_dir |
Directory where |
verbose |
Logical; if |
A data frame containing the rendered Table 1.
Zhen Lu
data("melanoma", package = "boot") melanoma2 <- melanoma melanoma2$status <- factor( melanoma2$status, levels = c(2, 1, 3), labels = c("Alive", "Melanoma death", "Non-melanoma death") ) Table1( df = melanoma2, ycol = "status", xcol = c("time", "age", "sex"), result_dir = tempdir() )data("melanoma", package = "boot") melanoma2 <- melanoma melanoma2$status <- factor( melanoma2$status, levels = c(2, 1, 3), labels = c("Alive", "Melanoma death", "Non-melanoma death") ) Table1( df = melanoma2, ycol = "status", xcol = c("time", "age", "sex"), result_dir = tempdir() )
Test speed of CRAN mirror
test_mirror(region, verbose = TRUE)test_mirror(region, verbose = TRUE)
region |
a character string, the region of the CRAN mirror, e.g. 'China' |
verbose |
logical, controlling the output |
This function is used to test the speed of CRAN mirror.
a data.frame with the name, URL, and download time of the fastest CRAN mirror
Zhen Lu
test_mirror('China')test_mirror('China')
Use wget to download files
use_wget(use = TRUE)use_wget(use = TRUE)
use |
a logical value, controlling the download method |
This function is used to set the download method.
a logical value indicating whether wget is used
Zhen Lu
use_wget(use = TRUE) getOption("download.file.method") getOption("download.file.extra") test_url <- "https://eternallybored.org/misc/wget/1.21.4/64/wget.exe" test_destfile <- tempfile() download.file(test_url, destfile = test_destfile)use_wget(use = TRUE) getOption("download.file.method") getOption("download.file.extra") test_url <- "https://eternallybored.org/misc/wget/1.21.4/64/wget.exe" test_destfile <- tempfile() download.file(test_url, destfile = test_destfile)