Package: kstools 0.6.1

Vladimir Larchenko

kstools: Clinical and Data Science Utilities

Utility functions for clinical trials and data science: descriptive statistics (summaries with optional custom stats, quartiles, median CI, geometric mean), SDTM/ADaM helpers (date conversion, supplemental merge, XPT batch load), table builders, batch data loading, and utilities (z-score, CV, SWOE, AUC, EAIR, Newcombe CIs, AR(1) simulation).

Authors:Vladimir Larchenko [aut, cre], Igor Aleschenkov [aut]

kstools_0.6.1.tar.gz
kstools_0.6.1.tgz(r-4.6-x86_64)kstools_0.6.1.tgz(r-4.6-arm64)kstools_0.6.1.tgz(r-4.5-x86_64)kstools_0.6.1.tgz(r-4.5-arm64)
kstools_0.6.1.tar.gz(r-4.7-arm64)kstools_0.6.1.tar.gz(r-4.7-x86_64)kstools_0.6.1.tar.gz(r-4.6-arm64)kstools_0.6.1.tar.gz(r-4.6-x86_64)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
kstools/json (API)

# Install 'kstools' in R:
install.packages('kstools', repos = c('https://crow16384.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/crow16384/kstools/issues

Uses libs:
  • c++– GNU Standard C++ Library v3

On CRAN:

Conda:

quartocpp

4.41 score 2 scripts 54 exports 35 dependencies

Last updated from:f0d76736a0. Checks:9 OK, 6 FAIL. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK201
linux-devel-x86_64OK165
source / vignettesOK306
linux-release-arm64OK151
linux-release-x86_64OK191
macos-release-arm64OK168
macos-release-x86_64OK664
macos-oldrel-arm64OK382
macos-oldrel-x86_64OK591
windows-devel-arm64FAIL355
windows-devel-x86_64FAIL88
windows-release-arm64FAIL355
windows-release-x86_64FAIL145
windows-oldrel-x86_64FAIL73
wasm-releaseFAIL148

Exports:%+na%ks_aligndecks_aucks_batch_loadks_batch_load_from_single_xptks_batch_load_xlsxks_be_2x2ks_boot_ciks_code_to_fmtks_compare_naks_current_filenameks_cvks_del_tmpks_desc_codedks_dtc2dtnks_dunnett_critks_eairdiff_mnks_eairdiff_strata_mnks_extract_single_xptks_geom_meanks_get_dataks_get_labelsks_get_numdecks_hosmer_lemeshowks_impute_dtcks_median_ciks_mianalyzeks_mv_normalityks_n_pctks_newcombe_hsks_newcombe_hs_strataks_p_normks_q1ks_q3ks_read_xptks_rocks_set_formatsks_set_labelsks_simulate_ar1ks_sum_naks_summaryks_supp_consistency_checkks_supp_mergeks_swap_colsks_swoeks_vswitchks_williamsks_write_xptks_xpt_contentks_xpt_formatsks_xpt_labelsks_z_scoremianalyzeread.csv3

Dependencies:bootclicpp11dplyrevaluategenericsgluehighrknitrksformatlatticelifecyclelubridatemagrittrMASSnlmeopenxlsx2pillarpkgconfigpurrrR6RcpprlangrootSolvestringistringrtibbletidyrtidyselecttimechangeutf8vctrswithrxfunyaml

Multiple Imputation Analysis with mianalyze()
Introduction | Multiple Imputation Workflow | Rubin's Rules | Pooled Estimate | Within-Imputation Variance | Between-Imputation Variance | Total Variance | Relative Increase in Variance | Fraction of Missing Information | Relative Efficiency | Degrees of Freedom | Rubin (1987) | Problem with Large-Sample Degrees of Freedom | Barnard-Rubin Adjustment | Basic Example | Example: Manual Verification | Example: Treatment Difference | Example: Odds Ratio Analysis | Example: Hazard Ratio Analysis | Example: Small-Sample Degrees of Freedom | Comparison with SAS PROC MIANALYZE | Option mapping | Scope | SAS Example 58.1 (means and standard errors, EDF=30) | Relative efficiency (SAS Table 58.2) | API correspondence | Typical Clinical Trial Workflow | Interpreting Output | Variance Components | Missing Information | Inference | Special Cases | Single Imputation | No Between-Imputation Variability | Summary | References

Last update: 2026-07-25
Started: 2026-07-18

Getting Started
Installation | Descriptive Summary | Pooled Estimate Across Imputations | Compare ROC Areas | SDTM Supplemental Merge | Next Steps

Last update: 2026-07-18
Started: 2026-04-08

Clinical Workflows
1. Incidence Rate and Proportion Comparisons | 2. Randomization Design | 3. Data Loaders

Last update: 2026-07-13
Started: 2026-04-08

Imputing Incomplete ISO 8601 Dates with ks_impute_dtc()
Overview | Imputation Logic | Step 1 — Parse | Step 2 — Completeness check | Step 3 — Imputation flags | Step 4 — Direction rules | Step 5 — Date-only strings with a directional imputation (Cases D and E) | Step 6 — Reference-guided imputation | Basic Examples | direction = "no" — no imputation | direction = "start" — earliest plausible values | direction = "end" — latest plausible values | Leap-Year End-of-Month | Reference-Guided Imputation | Case A — day missing, year + month match ref | Case B — month missing, year matches ref | Case C — date complete, time absent, date matches ref | Vectorised Use with dplyr

Last update: 2026-05-22
Started: 2026-05-22

Readme and manuals

Help Manual

Help pageTopics
Align decimal (or first space) in character vectorks_aligndec
Area Under the Curve (AUC) by the trapezoidal ruleks_auc
Batch load files from a directory or ZIPks_batch_load
Load or save all datasets from a multi-member SAS XPORT v8/v9 fileks_batch_load_from_single_xpt
Backwards-compatible wrapper for 'ks_batch_load' with 'type = "xlsx"'ks_batch_load_xlsx
Bioequivalence: 2x2 crossover analysisks_be_2x2
Bootstrap confidence interval for a scalar statisticks_boot_ci
Build a named format vector from a coded columnks_code_to_fmt
NA-aware element-wise comparisonks_compare_na
Get the filename of the currently executing R scriptks_current_filename
Coefficient of variationks_cv
Remove temporary objects from global environmentks_del_tmp
Summarise hierarchically coded clinical itemsks_desc_coded
Convert DTC (date-time character) to Dateks_dtc2dtn
Exact Dunnett critical value (multivariate-t)ks_dunnett_crit
Miettinen-Nurminen CI for the difference of two incidence ratesks_eairdiff_mn
Stratified Miettinen-Nurminen CI for the difference of incidence ratesks_eairdiff_strata_mn
Extract one dataset from a multi-member SAS XPORT v8/v9 fileks_extract_single_xpt
Geometric mean and confidence intervalks_geom_mean
Load domain files and return themks_get_data
Get variable labels from a data frameks_get_labels
Compute the maximum number of decimal places per groupks_get_numdec
Hosmer–Lemeshow goodness-of-fit testks_hosmer_lemeshow
Impute incomplete ISO 8601 date/datetime stringsks_impute_dtc
Confidence interval for the medianks_median_ci
Analogue of SAS PROC MIANALYZE (Rubin pooling)knit_print.ks_mianalyze ks_mianalyze mianalyze summary.ks_mianalyze
Multivariate normality tests (Mardia, energy)ks_mv_normality
Format count and percentage pairsks_n_pct
Newcombe Hybrid Score CI for a difference of two proportionsks_newcombe_hs
Stratified Newcombe Hybrid Score CI for a difference of two proportionsks_newcombe_hs_strata
Normality test p-valueks_p_norm
25th percentile (Q1)ks_q1
75th percentile (Q3)ks_q3
Read a SAS XPORT (.xpt) fileks_read_xpt
Compare correlated ROC curve areas (AUC) via Mann-Whitney contrastsks_roc
Set SAS variable formats on a data frameks_set_formats
Set SAS variable labels on a data frameks_set_labels
Simulate longitudinal data with AR(1) within-subject errorsks_simulate_ar1
Add two values ignoring NA%+na% ks_sum_na
Descriptive summary for continuous variablesks_summary
Check SDTM supplemental dataset structureks_supp_consistency_check
Merge an SDTM supplemental domain with its primary domainks_supp_merge
Swap pairs of columns in a data frameks_swap_cols
Smoothed weight of evidence (SWOE) for categorical predictorsks_swoe
Vectorized switch (SAS select-when maps)ks_vswitch
Build a randomized Williams cross-over design and scheduleks_williams
Write a data frame to a SAS XPORT (.xpt) fileks_write_xpt
List datasets inside a SAS XPORT v8/v9 fileks_xpt_content
Get SAS variable formats from a data frameks_xpt_formats
Get SAS variable labels from a data frameks_xpt_labels
Calculate Z scoreks_z_score
Read CSV file with column types and lengths in commentsread.csv3