Learn R Programming

climatehealth (version 1.0.0)

run_descriptive_stats_api: Create descriptive statistics via API-friendly inputs.

Description

Create descriptive statistics via API-friendly inputs.

Usage

run_descriptive_stats_api(
  data,
  output_path,
  aggregation_column = NULL,
  population_col = NULL,
  dependent_col,
  independent_cols,
  units = NULL,
  plot_corr_matrix = FALSE,
  plot_dist = FALSE,
  plot_ma = FALSE,
  plot_na_counts = FALSE,
  plot_scatter = FALSE,
  plot_box = FALSE,
  plot_seasonal = FALSE,
  plot_regional = FALSE,
  plot_total = FALSE,
  correlation_method = "pearson",
  ma_days = 100,
  ma_sides = 1,
  timeseries_col = NULL,
  detect_outliers = FALSE,
  calculate_rate = FALSE,
  run_id = NULL,
  create_base_dir = TRUE
)

Value

A list with base_output_path, run_id, run_output_path, and region_output_paths.

Arguments

data

The dataset for descriptive stats (list-like object or CSV path).

output_path

Character. Base output directory.

aggregation_column

Character. Column used to aggregate/split data by region.

population_col

Character. The column containing the population.

dependent_col

Character. The dependent column.

independent_cols

Character vector. The independent columns.

units

Named character vector. Units for each variable.

plot_corr_matrix

Logical. Whether to plot a correlation matrix.

plot_dist

Logical. Whether to plot histograms.

plot_ma

Logical. Whether to plot moving averages over a timeseries.

plot_na_counts

Logical. Whether to plot counts of NAs in each column.

plot_scatter

Logical. Whether to plot dependent vs independent columns.

plot_box

Logical. Whether to generate box plots for selected columns.

plot_seasonal

Logical. Whether to plot seasonal trends.

plot_regional

Logical. Whether to plot regional trends.

plot_total

Logical. Whether to plot total dependent values per year.

correlation_method

Character. Correlation method. One of 'pearson', 'spearman', 'kendall'.

ma_days

Integer. Number of days used in moving average calculations.

ma_sides

Integer. Number of sides used in moving average calculations (1 or 2).

timeseries_col

Character. Timeseries column.

detect_outliers

Logical. Whether to output an outlier table.

calculate_rate

Logical. Whether to plot annual rates per 100k.

run_id

Character. Optional run id.

create_base_dir

Logical. Whether to create output_path if missing. Defaults to TRUE.

Examples

Run this code
# \donttest{
run_descriptive_stats_api(
  data = list(
    date = as.character(as.Date("2024-01-01") + 0:29),
    region = rep(c("A", "B"), each = 15),
    outcome = sample(1:20, 30, replace = TRUE),
    temp = rnorm(30, 25, 3)
  ),
  output_path = tempdir(),
  aggregation_column = "region",
  dependent_col = "outcome",
  independent_cols = c("temp"),
  timeseries_col = "date",
  plot_corr_matrix = TRUE
)
# }

Run the code above in your browser using DataLab