| Title: | Interactive Training App for Data Science and AI Skills |
|---|---|
| Description: | An interactive 'shiny' training companion for people who are new to data, developed for World Health Organization data trainings. Bundles hands-on modules for importing data, missing values, outliers, text cleaning, merging, visualization, and basic statistics, plus a set of AI-skills pages (prompting levels, four practical tasks, AI safety rules, and a methodology case study) and an interactive quiz with per-session topic filters. Includes reusable data-quality, plotting and reporting functions. Launch the cat classroom with run_cata(). |
| Authors: | Shanlong Ding [aut, cre] (ORCID: <https://orcid.org/0000-0001-9048-6670>) |
| Maintainer: | Shanlong Ding <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 3.0.0 |
| Built: | 2026-11-23 16:54:47 UTC |
| Source: | https://github.com/cran/cataScience |
Check a proposed record key
cata_check_keys(data, key)cata_check_keys(data, key)
data |
A data frame. |
key |
Character vector of key column names. |
A list with a one-row summary, per-row flags, and all
review_rows. Every member of a repeated-key or identical-row group is
flagged. Repeated IDs are not automatically deleted.
cata_check_keys(data.frame(id = c("A", "A", NA), value = 1:3), "id")cata_check_keys(data.frame(id = c("A", "A", NA), value = 1:3), "id")
Summarise a reported binary status with unknowns kept visible
cata_count_status(data, status, yes = "Yes", no = "No", by = NULL)cata_count_status(data, status, yes = "Yes", no = "No", by = NULL)
data |
A data frame. |
status |
Status column name. |
yes, no
|
Distinct character labels for success and failure. |
by |
Optional grouping column name. |
A tibble with records, yes, no, unknown, blank, known denominator and percent. Unknown/blank statuses are excluded from the denominator and reported separately. The measure is reported status, not verified service/result availability.
cata_count_status(data.frame(test = c("Yes", "No", "Unknown", NA)), "test")cata_count_status(data.frame(test = c("Yes", "No", "Unknown", NA)), "test")
Load a documented example
cata_example(name = NULL)cata_example(name = NULL)
name |
Example name. NULL returns the catalogue. |
A tibble with a cata_source attribute, or the catalogue.
cata_example() cats <- cata_example("cats")cata_example() cats <- cata_example("cats")
Writes a new directory containing input and selected-data snapshots, an R script, report and dashboard HTML, Quarto sources, and a local Shiny dashboard. The R script reconstructs selected data using the supplied preparation steps, then recomputes summaries and the chart. It uses an input RDS snapshot to preserve identifiers, factors, dates and column types.
cata_export( data, directory, input = data, steps = character(), join_data = NULL, plot_args = NULL, summary_spec = NULL, chart_data = c("records", "summary"), audit = NULL, title = "Data analysis report", question = "", methods = "", finding = "", limitations = "", source = "", unit = "", denominator = "", width = 8, height = 5 )cata_export( data, directory, input = data, steps = character(), join_data = NULL, plot_args = NULL, summary_spec = NULL, chart_data = c("records", "summary"), audit = NULL, title = "Data analysis report", question = "", methods = "", finding = "", limitations = "", source = "", unit = "", denominator = "", width = 8, height = 5 )
data |
Selected analysis data. |
directory |
A new output directory; existing directories are protected. |
input |
Original input snapshot, before the listed preparation steps. |
steps |
Character vector of R preparation statements, each operating
on |
join_data |
Optional reference-table snapshot used by preparation steps. |
plot_args |
Named arguments for |
summary_spec |
Optional arguments for |
chart_data |
Use selected records or the status summary for the chart. |
audit |
Optional preparation log. |
title, question, methods, finding, limitations, source, unit, denominator
|
Author-supplied report text. |
width, height
|
Figure dimensions in inches, retained in the project. |
The new directory, invisibly. Source files are generated even when Quarto is not installed. HTML exports need neither Quarto nor a server.
out <- tempfile("cata-project-") cata_export(data.frame(value = 1:5), out, title = "Example report")out <- tempfile("cata-project-") cata_export(data.frame(value = 1:5), out, title = "Example report")
An IQR flag is a screening result, not evidence of an erroneous value.
Use explicit limits only when a documented rule supports them.
cata_flag_outliers(x, k = 1.5, limits = NULL)cata_flag_outliers(x, k = 1.5, limits = NULL)
x |
A numeric vector. |
k |
Non-negative multiplier for the IQR rule. |
limits |
Optional numeric lower and upper limits (inclusive). |
A tibble retaining every row and value, with bounds, a review flag, and a reason. Missing values receive an unknown outlier flag.
cata_flag_outliers(c(1:9, 100, NA))cata_flag_outliers(c(1:9, 100, NA))
Join tables and return an audit
cata_join( x, y, by, type = c("left", "inner", "full", "right"), relationship = "many-to-one", na_matches = "never", suffix = c(".x", ".y") )cata_join( x, y, by, type = c("left", "inner", "full", "right"), relationship = "many-to-one", na_matches = "never", suffix = c(".x", ".y") )
x, y
|
Data frames. |
by |
Character join keys, optionally named to match different names. |
type |
Join type. |
relationship |
Expected key relationship; checked by dplyr. |
na_matches |
Whether missing keys can match. Defaults to |
suffix |
Suffixes for overlapping non-key columns. |
A list containing data, audit, both key checks, and unmatched
input rows. Input tables are unchanged.
cata_join(data.frame(id = c(1, 2, NA)), data.frame(id = 1:2, label = c("A", "B")), by = "id")cata_join(data.frame(id = c(1, 2, NA)), data.frame(id = 1:2, label = c("A", "B")), by = "id")
A fixed teaching simulation with missing weights. Fits the same linear model to each completed dataset and pools model estimates, not datasets. It does not impute uploaded records. Diagnostic plots do not establish that the missingness assumptions hold in a real study.
cata_mice_demo(m = 5, maxit = 5, seed = 2026)cata_mice_demo(m = 5, maxit = 5, seed = 2026)
m |
Number of imputations, from 2 to 20. |
maxit |
Number of iterations, from 2 to 20. |
seed |
Integer seed for reproducibility. The caller's random-number state is restored on exit. |
A list with complete and incomplete synthetic data, the mids
object, completed datasets, pooled model estimates and a comparison of
the complete-data, complete-case, mean-imputed and pooled slopes.
demo <- cata_mice_demo(m = 3, maxit = 3) demo$comparisondemo <- cata_mice_demo(m = 3, maxit = 3) demo$comparison
Count missing values and patterns
cata_missing(data, by = c("variable", "record", "pattern"))cata_missing(data, by = c("variable", "record", "pattern"))
data |
A data frame. |
by |
Summary level: variables, records, or missingness patterns. |
A tibble. Patterns use 1 for missing and 0 for observed, in
input column order; the variables attribute records that order.
cata_missing(data.frame(a = c(1, NA), b = c(NA, NA)))cata_missing(data.frame(a = c(1, NA), b = c(NA, NA)))
Returns an editable ggplot object. Bar charts count rows when y is NULL;
supplying y uses already summarised values and requires unique chart
keys. Lines also require one value per x/group/facet. Charts omit rows
missing a required measurement and report that count in the caption.
Missing categories in comparison charts are labelled explicitly.
cata_plot( data, type = "bar", x, y = NULL, group = NULL, facet = NULL, value = NULL, yend = NULL, lower = NULL, upper = NULL, title = NULL, subtitle = NULL, caption = NULL, xlab = NULL, ylab = NULL, sort = FALSE, percent = FALSE, bins = 10, style = "cata", log_scale = FALSE, reference = 1 )cata_plot( data, type = "bar", x, y = NULL, group = NULL, facet = NULL, value = NULL, yend = NULL, lower = NULL, upper = NULL, title = NULL, subtitle = NULL, caption = NULL, xlab = NULL, ylab = NULL, sort = FALSE, percent = FALSE, bins = 10, style = "cata", log_scale = FALSE, reference = 1 )
data |
A data frame. |
type |
Chart type: bar, histogram, density, line, scatter, box, dot, heatmap, dumbbell, forest, or cascade. |
x, y
|
Names of axis variables. |
group, facet
|
Optional grouping and faceting variable names. |
value |
Numeric fill variable for a heatmap. |
yend |
Second numeric value for a dumbbell chart. |
lower, upper
|
Numeric confidence-limit columns for a forest plot. |
title, subtitle, caption
|
Plot text. |
xlab, ylab
|
Optional axis labels, including units where appropriate. |
sort |
Sort a single-series bar/dot/dumbbell by its value. |
percent |
Whether values are percentages on a 0 to 100 scale. |
bins |
Number of histogram bins. |
style |
Built-in |
log_scale |
Use a logarithmic estimate axis for a forest plot. |
reference |
Reference value for a forest plot (1 for an odds ratio). |
A ggplot object with a cata_rows attribute describing input,
plotted, and omitted rows.
d <- data.frame(district = c("A", "B"), percent = c(75, 68)) cata_plot(d, "dot", "district", "percent", percent = TRUE)d <- data.frame(district = c("A", "B"), percent = c(75, 68)) cata_plot(d, "dot", "district", "percent", percent = TRUE)
Summarise the structure and quality of a table
cata_profile(data)cata_profile(data)
data |
A data frame. |
One row per variable, with storage type, record count, observed unique values, missingness, and numeric summaries. No values are changed.
cata_profile(data.frame(id = c("001", "002"), value = c(3, NA)))cata_profile(data.frame(id = c("001", "002"), value = c(3, NA)))
Calculate proportions with explicit denominators
cata_proportion(numerator, denominator, scale = 100)cata_proportion(numerator, denominator, scale = 100)
numerator, denominator
|
Numeric counts of equal length, or one scalar. |
scale |
Multiplier, usually 100 for percentages. |
A tibble with the input counts, value, and status. Invalid
counts and zero denominators produce NA, with the reason retained.
cata_proportion(c(200, 233, 0), c(265, 315, 0))cata_proportion(c(200, 233, 0), c(265, 315, 0))
Read a CSV or Excel table without modifying the source file. Specify column
types when identifiers contain leading zeroes. Excel notes and footers can
be excluded with range.
cata_read( path, format = tools::file_ext(path), sheet = 1, range = NULL, col_types = NULL, na = c("", "NA") )cata_read( path, format = tools::file_ext(path), sheet = 1, range = NULL, col_types = NULL, na = c("", "NA") )
path |
Path to an existing file. |
format |
File extension ( |
sheet |
Excel sheet name or number. |
range |
Optional Excel cell range. |
col_types |
Column specification passed to the selected reader. |
na |
Character values to interpret as missing. |
A tibble. CSV parsing problems remain available through
readr::problems().
cats <- cata_example("cats") cata_profile(cats)cats <- cata_example("cats") cata_profile(cats)
Creates a local HTML file with no online resources. Text is escaped;
narrative findings and limitations come from the author. The dashboard
includes local table search. For editable and reproducible source files,
use cata_export().
cata_report( data, file, title = "Data analysis report", question = "", methods = "", finding = "", limitations = "", source = "", unit = "", denominator = "", plot = NULL, tables = list(), audit = NULL, format = c("report", "dashboard"), width = 8, height = 5, overwrite = FALSE )cata_report( data, file, title = "Data analysis report", question = "", methods = "", finding = "", limitations = "", source = "", unit = "", denominator = "", plot = NULL, tables = list(), audit = NULL, format = c("report", "dashboard"), width = 8, height = 5, overwrite = FALSE )
data |
Data frame describing the selected analysis records. |
file |
Output HTML path. Existing files are protected by default. |
title, question, methods, finding, limitations, source, unit, denominator
|
Author-supplied report text. Missing text is displayed as "Not provided". |
plot |
Optional ggplot figure. |
tables |
Named list of data frames to include before the data profile. |
audit |
Optional data frame of preparation/selection steps. |
format |
Report or dashboard layout. |
width, height
|
Figure dimensions in inches. |
overwrite |
Explicitly allow replacing an existing output file. |
The output path, invisibly.
f <- tempfile(fileext = ".html") cata_report(data.frame(value = 1:3), f, title = "Teaching example")f <- tempfile(fileext = ".html") cata_report(data.frame(value = 1:3), f, title = "Teaching example")
Starts the interactive training app bundled with the package: import, clean, visualize, and understand data, then learn to work with AI assistants safely. The app opens in your default browser.
run_cata(..., language = c("auto", "en", "zh"))run_cata(..., language = c("auto", "en", "zh"))
... |
Passed on to |
language |
Interface language: |
No return value; called for the side effect of launching the app. The function blocks the R session while the app is running.
# The app is bundled with the package and launched from its own directory. app_dir <- system.file("app", package = "cataScience") file.exists(file.path(app_dir, "app.R")) # Starting the app needs an interactive session, since it blocks R until # the browser window is closed. if (interactive()) { run_cata() }# The app is bundled with the package and launched from its own directory. app_dir <- system.file("app", package = "cataScience") file.exists(file.path(app_dir, "app.R")) # Starting the app needs an interactive session, since it blocks R until # the browser window is closed. if (interactive()) { run_cata() }
A clear theme for training figures
theme_cata(base_size = 13, style = c("cata", "dsi"))theme_cata(base_size = 13, style = c("cata", "dsi"))
base_size |
Base text size in points. |
style |
Use the built-in theme or the optional DSIR theme. |
A ggplot2 theme.
theme_cata()theme_cata()