Title: | Supporting Functions Maintained by Zhen Lu |
Version: | 0.0.4 |
Description: | Miscellaneous functions commonly used by LuLab. This package aims to help more researchers on epidemiology to perform data management and visualization more efficiently. |
License: | Artistic-2.0 |
URL: | https://leslie-lu.github.io/ |
BugReports: | https://github.com/Leslie-Lu/lulab.utils/issues |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.1 |
Imports: | boot, car, descr, dplyr, httr2, magrittr, openxlsx, purrr, rappdirs, stringr, table1, utils |
Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) |
VignetteBuilder: | knitr |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2024-10-07 16:01:55 UTC; luzh2 |
Author: | Zhen Lu |
Maintainer: | Zhen Lu <luzh29@mail2.sysu.edu.cn> |
Repository: | CRAN |
Date/Publication: | 2024-10-07 16:20:02 UTC |
lulab.utils: 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.
Author(s)
Maintainer: Zhen Lu luzh29@mail2.sysu.edu.cn (ORCID)
See Also
Useful links:
Table1
Description
Make Table1
Usage
Table1(df, ycol, xcol, xlabels, result_dir, verbose = TRUE)
Arguments
df |
a data.frame |
ycol |
a grouping variable |
xcol |
variables to be compared |
xlabels |
levels of ycol |
result_dir |
directory to save the result |
verbose |
logical, controlling the output |
Details
This function is used to make Table1 and return excel file.
Value
excel file
Author(s)
Zhen Lu
Examples
data("melanoma", package = "boot")
melanoma2 <- melanoma
# Factor the basic variables that
# we're interested in
melanoma2$status <-
factor(melanoma2$status,
levels=c(2,1,3),
labels=c("Alive", # Reference
"Melanoma death",
"Non-melanoma death"))
test= Table1(
df= melanoma2,
xcol= setdiff(names(melanoma2), "status"),
ycol= "status",
result_dir= tempdir()
)
check_cha
Description
Check for missing values for character columns
Usage
check_cha(col, df, verbose = TRUE)
Arguments
col |
a character variable name |
df |
a data.frame |
verbose |
logical, controlling the output |
Details
This function is used to check the distribution of character variables in the data frame.
Value
a distribution table of the character variable in the data frame
Author(s)
Zhen Lu
Examples
data("melanoma", package = "boot")
melanoma2 <- melanoma
check_cha('status', melanoma2)
# or
mapply(check_cha,'status', MoreArgs= list(melanoma2))
check_wget
Description
Check if wget is installed
Usage
check_wget()
Details
This function is used to check if wget is installed on the system.
Value
a logical value indicating whether wget is installed
Author(s)
Zhen Lu
Examples
check_wget()
test_mirror
Description
Test speed of CRAN mirror
Usage
test_mirror(region, verbose = TRUE)
Arguments
region |
a character string, the region of the CRAN mirror, e.g. 'China' |
verbose |
logical, controlling the output |
Details
This function is used to test the speed of CRAN mirror.
Value
a data.frame with the name, URL, and download time of the fastest CRAN mirror
Author(s)
Zhen Lu
Examples
test_mirror('China')
use_wget
Description
Use wget to download files
Usage
use_wget(use = TRUE)
Arguments
use |
a logical value, controlling the download method |
Details
This function is used to set the download method.
Value
a logical value indicating whether wget is used
Author(s)
Zhen Lu
Examples
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)