| Type: | Package |
| Title: | Descriptive, Reliability, and Inferential Tables for Psychometric Scales and Demographic Data |
| Version: | 0.1.3 |
| Description: | Provides functions to format and summarise already computed outputs from commonly used statistical and psychometric functions into compact, single-row tables and simple graphs, with utilities to export results to CSV, Word, and Excel formats. The package does not implement new statistical methods or estimation procedures; instead, it organises and presents results obtained from existing functions such as psych::describe(), psych::alpha(), stats::t.test(), and gtsummary::tbl_summary() to streamline reporting workflows in clinical and psychological research. |
| License: | MIT + file LICENSE |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| Imports: | dplyr, gtsummary, purrr, rlang, stats, officer, openxlsx, utils |
| Suggests: | psych, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | no |
| Packaged: | 2026-02-05 03:12:52 UTC; HP |
| Author: | Darshan Dharaiya |
| Maintainer: | Darshan Dharaiya <dharaiya.darshan@gmail.com> |
| Depends: | R (≥ 4.1.0) |
| Repository: | CRAN |
| Date/Publication: | 2026-02-08 17:00:10 UTC |
Wrap a pre-computed psych::alpha object into a single-row table
Description
Wrap a pre-computed psych::alpha object into a single-row table
Usage
make_alpha_table(alpha_res, scale_name = "Scale")
Arguments
alpha_res |
A psych::alpha object (already computed) |
scale_name |
Name of the scale (default: "Scale") |
Value
A data frame with columns: Scale, 95% CI lower, Alpha, 95% CI upper
Examples
# Create a minimal "psych::alpha" like object manually
alpha_obj <- list(
total = list(
raw_alpha = 0.85,
lower = 0.78,
upper = 0.92
)
)
# Generate the formatted alpha table
make_alpha_table(alpha_obj, scale_name = "PHQ-9")
Export a data frame to CSV, Word, or Excel
Description
This function writes a data frame to a user-specified file path in a user-specified format (CSV, Word, or Excel).
CSV uses
write.csv()Word (
docx) usesofficerand makes column names safeExcel (
xlsx) usesopenxlsx
Usage
make_dataframe_to_output(x, filename = NULL, format = "csv")
Arguments
x |
A data frame to export |
filename |
Optional. The file name (with or without path, without extension). If not provided, the data frame name is used. |
format |
Character. One of |
Value
Invisible path to the generated file
Examples
df <- data.frame(x = 1:3, y = c("A", "B", "C"))
# Write to a temporary directory (CRAN-safe)
tmp_file <- file.path(tempdir(), "demo_csv")
make_dataframe_to_output(df, filename = tmp_file, format = "csv")
Create a demographics summary table
Description
Create a demographics summary table
Usage
make_demographic_table(data, vars, continuous_vars = NULL)
Arguments
data |
A data frame |
vars |
demographic variables to include in the table |
continuous_vars |
Optional subset of vars to be treated as continuous |
Value
A gtsummary table
Examples
# Minimal example data
df <- data.frame(
age = c(25, 30, 35),
sex = c("M", "F", "M"),
education = c("HS", "BA", "MA")
)
# Generate a demographic summary table (assign to object to avoid printing)
demo_table <- make_demographic_table(df, vars = c("age", "sex", "education"))
demo_table # optionally inspect the table
Create a one-row summary table of a paired t-test
Description
This function performs a paired t-test between two numeric variables in a data frame and returns a one-row summary table including means, mean difference, t-value, degrees of freedom, p-value, and confidence interval.
Usage
make_paired_t_test_table(
data,
var1,
var2,
var_name = NULL,
alternative = "two.sided",
conf.level = 0.95
)
Arguments
data |
A data frame containing the two numeric variables. |
var1 |
Character string. Name of the first variable (observation 1) in |
var2 |
Character string. Name of the second variable (observation 2) in |
var_name |
Optional character string. Custom name for the variable to display in the table. Default is |
alternative |
Character string specifying the alternative hypothesis. One of |
conf.level |
Confidence level for the interval. Default is 0.95. |
Value
A one-row data frame with columns:
-
Variable- variable name -
Mean_obs1- mean of observation 1 -
Mean_obs2- mean of observation 2 -
Mean_diff- mean difference (obs1 - obs2) -
t_value- t statistic -
df- degrees of freedom -
p_value- p-value -
CI_lower- lower bound of confidence interval -
CI_upper- upper bound of confidence interval
Examples
# example data
df <- data.frame(
before = c(10, 12, 14, 15, 11),
after = c(11, 13, 13, 16, 12)
)
# Run the paired t-test summary
make_paired_t_test_table(df, var1 = "before", var2 = "after")
Create a Descriptive Statistics Table Row
Description
Formats a descriptive statistics object into a single-row data frame
Usage
make_scale_description_table(descr_object, scale_name)
Arguments
descr_object |
An object returned by |
scale_name |
A single character string specifying the name of the scale. |
Details
This function is intended for reporting descriptive statistics of total scores that has been calculated using psych::describe().
Value
A single-row data frame with formatted descriptive statistics.
Examples
{
# Create 10 random PHQ-9 scores
phq9_data <- as.data.frame(matrix(sample(0:3, 10 * 9, replace = TRUE), 10, 9))
colnames(phq9_data) <- paste0("Q", 1:9)
phq9_data$total <- rowSums(phq9_data)
descr_total <- psych::describe(phq9_data$total)
make_scale_description_table(descr_total, scale_name = "PHQ-9")
}
scaledescr
Description
Provides helper functions to format and summarise already computed outputs from commonly used statistical and psychometric functions into compact, single-row tables and simple graphs. Functions such as make_scale_description_table(), make_demographic_table(), make_alpha_table(), make_paired_t_test_table(), and make_dataframe_to_output() organise results obtained from existing functions including psych::describe(), psych::alpha(), stats::t.test(), and gtsummary::tbl_summary() for streamlined reporting and export to CSV, Word, and Excel formats. The package does not implement new statistical methods or perform additional estimation.