Descriptive Statistics Analysis

Description

Computes descriptive statistics for selected variables and returns a structured results list consistent with the other *_answers() functions in the package. This is a convenience wrapper around univariate_stats_answers() that selects the requested variables and packages the output for use with create_descriptives_checker() and create_apa_univariates_table().

Usage

descriptives_answers(data, vars = NULL)

Arguments

data A data frame.
vars Character vector. Variable names to include in the analysis. If NULL (default), all columns are used.

Value

A list with elements:

Descriptives
A tibble with columns variable, mean, sd, n, and sem. All values are unrounded.
Sample_Size
Integer. Number of rows in the (subsetted) data.

See Also

univariate_stats_answers(), create_descriptives_checker(), create_apa_univariates_table()

Examples

library("psych350lab")

data(superman, package = "psych350data")
library(dplyr)

my_data <- superman |>
  select(num, year, clark_height_in, clark_grp, height_diff) |>
  filter(!is.na(height_diff))

result <- descriptives_answers(my_data,
  vars = c("year", "clark_height_in", "height_diff")
)
result$Descriptives
# A tibble: 3 × 5
  variable           mean    sd     n   sem
  <chr>             <dbl> <dbl> <int> <dbl>
1 year            1993.   28.4      9 9.47 
2 clark_height_in   73.7   1.73     9 0.577
3 height_diff        8.40  2.32     9 0.774
result$Sample_Size
[1] 9