| Title: | Publication-Ready Descriptive, Bivariate, Regression, and Diagnostic Accuracy Tools for Medical and Dental Data |
|---|---|
| Description: | The 'dentomedical' package provides a comprehensive suite of tools for medical and dental research. It includes automated descriptive statistics, bivariate analysis with intelligent test selection, logistic regression, and diagnostic accuracy assessment. All functions generate structured, publication-ready tables using 'flextable', ensuring reproducibility and clarity suitable for manuscripts, reports, and clinical research workflows. |
| Authors: | Umar Hussain [aut, cre] |
| Maintainer: | Umar Hussain <[email protected]> |
| License: | MIT |
| Version: | 0.1.0 |
| Built: | 2026-05-13 07:29:37 UTC |
| Source: | https://github.com/umarhussain-git/dentomedical |
Calculates diagnostic accuracy measures (Sensitivity, Specificity, PPV, NPV, Accuracy, LR+, LR-, DOR) from a binary test and gold standard. Provides 95% confidence intervals using Wilson method for proportions and log method for ratios. Optionally, prints a descriptive 2x2 table.
diag_accuracy(data, test_col, gold_col, descriptive = FALSE)diag_accuracy(data, test_col, gold_col, descriptive = FALSE)
data |
A data frame containing the test results and gold standard. |
test_col |
Character. Name of the column in |
gold_col |
Character. Name of the column in |
descriptive |
Logical. If TRUE, prints a descriptive 2x2 table with counts (TN, TP, FP, FN). Default is FALSE. |
A flextable object summarizing diagnostic metrics with 95% CI.
If descriptive = TRUE, also prints a 2x2 table of counts.
diagnostic_data <- data.frame( test = c("positive","negative","positive","negative","positive","negative","positive","negative"), goldstandard = c("positive","positive","negative","negative","positive","negative","positive","negative") ) diag_accuracy(diagnostic_data, test_col = "test", gold_col = "goldstandard", descriptive = TRUE)diagnostic_data <- data.frame( test = c("positive","negative","positive","negative","positive","negative","positive","negative"), goldstandard = c("positive","positive","negative","negative","positive","negative","positive","negative") ) diag_accuracy(diagnostic_data, test_col = "test", gold_col = "goldstandard", descriptive = TRUE)
This function performs univariate and multivariate linear regression analyses for the specified predictors and outcome variable, returning a summary table with characteristics, regression coefficients (β) with 95% CI, and p-values. Numeric variables show mean (SD); categorical variables show n (%). Multivariate model R² and adjusted R² are included in the table footer.
linreg(data, outcome, predictors)linreg(data, outcome, predictors)
data |
A data frame or tibble containing the variables. |
outcome |
The name of the outcome variable (numeric) as a string. |
predictors |
A character vector of predictor variable names. |
A flextable object summarizing univariate and multivariate linear regression results.
# Example using built-in iris dataset linreg(iris, outcome = "Sepal.Length", predictors = c("Sepal.Width", "Petal.Length", "Species"))# Example using built-in iris dataset linreg(iris, outcome = "Sepal.Length", predictors = c("Sepal.Width", "Petal.Length", "Species"))
Performs logistic regression for a binary outcome and a set of predictor variables. Computes both univariate and multivariate odds ratios (ORs) with 95% confidence intervals and p-values. Categorical variables automatically include a reference level in the output. Results are returned as a formatted flextable.
logreg(data, outcome, predictors)logreg(data, outcome, predictors)
data |
A data frame containing the outcome and predictor variables. |
outcome |
A character string (factor)specifying the binary outcome variable. |
predictors |
A character vector (factor) of predictor variables to include in the regression. |
A flextable displaying univariate and multivariate odds ratios (95% CI) and p-values for each predictor. Reference levels for categorical variables are labeled "Reference".
logreg(data=medical_data(), outcome="case" , predictors= c("age" , "parity" , "induced" ))logreg(data=medical_data(), outcome="case" , predictors= c("age" , "parity" , "induced" ))
Load Infertility Dataset
medical_data()medical_data()
A data.frame containing infertility cases with labeled predictors suitable for logistic regression
This function performs the Shapiro-Wilk normality test on all numeric variables
in a dataset and returns the results in a publication-ready flextable.
Extremely small p-values are displayed as "p < 0.001". The function
automatically detects numeric variables and ignores non-numeric columns.
norm.sum(data, sample_size = 5000)norm.sum(data, sample_size = 5000)
data |
A data frame containing numeric and non-numeric variables. Only numeric variables are assessed for normality. |
sample_size |
Integer. Maximum number of observations to use for the Shapiro-Wilk test per variable (default = 5000). |
A flextable summarizing each numeric variable with Shapiro-Wilk
W statistic, formatted p-value, and distribution classification
("Normal" or "Skewed").
norm.sum(iris)norm.sum(iris)
This function generates descriptive summary tables for both continuous and categorical variables. Continuous variables can be summarized using mean (SD) or median (IQR), and categorical variables are summarized as counts and percentages. Optionally, summaries can be stratified by a grouping variable.
## S3 method for class 'stat' sum(data, by = NULL, statistic = "mean_sd")## S3 method for class 'stat' sum(data, by = NULL, statistic = "mean_sd")
data |
A data frame containing the variables to summarize. |
by |
Optional. A grouping variable (column name as string) to stratify the summary table. |
statistic |
Character. Summary statistic for continuous variables. Either |
A flextable object displaying the summary table with appropriate formatting for publication or reporting.
Continuous variables show mean (SD) or median (IQR), and categorical variables show counts and percentages.
If by is specified, summaries are presented for each group in separate columns.
sum.stat(iris) sum.stat(iris, by = "Species", statistic = "mean_sd") sum.stat(iris, statistic = "med_iqr")sum.stat(iris) sum.stat(iris, by = "Species", statistic = "mean_sd") sum.stat(iris, statistic = "med_iqr")
sum.stat.p() generates a descriptive summary table for both categorical and
continuous variables stratified by a grouping variable. It automatically
computes appropriate statistical tests (Chi-square, Fisher's exact, t-test,
Wilcoxon, ANOVA, or Kruskal–Wallis) based on data type and distribution
characteristics. The output is formatted as a flextable with footnotes
indicating the summary statistics used and the tests applied.
## S3 method for class 'stat.p' sum(data, by, statistic = "mean_sd", test_type = "auto")## S3 method for class 'stat.p' sum(data, by, statistic = "mean_sd", test_type = "auto")
data |
A data frame or tibble containing variables to summarise. |
by |
A string specifying the grouping variable name. Must be a column in |
statistic |
A string specifying summary style for continuous variables:
|
test_type |
Optionally force a specific test. Choices:
|
A flextable object containing the summary table with p-values and
footer notes describing summary statistics and tests used.
# Load built-in dataset data(CO2) # Example 1: Auto test selection, median/IQR summary sum.stat.p(CO2, by = "Type", statistic = "med_iqr") # Example 2: Force Wilcoxon test for continuous variables sum.stat.p(CO2, by = "Type", statistic = "med_iqr", test_type = "wilcox") # Example 3: Mean/SD with automatic test choice sum.stat.p(CO2, by = "Treatment", statistic = "mean_sd")# Load built-in dataset data(CO2) # Example 1: Auto test selection, median/IQR summary sum.stat.p(CO2, by = "Type", statistic = "med_iqr") # Example 2: Force Wilcoxon test for continuous variables sum.stat.p(CO2, by = "Type", statistic = "med_iqr", test_type = "wilcox") # Example 3: Mean/SD with automatic test choice sum.stat.p(CO2, by = "Treatment", statistic = "mean_sd")