descriptive.statistics: Descriptive Statistics

descriptive.statisticsR Documentation

Descriptive Statistics

Description

This function computes descriptive statistics for specified variables in a dataset, optionally grouped by certain categorical variables. The function returns a tidy data frame containing the summaries of the selected variables, including relevant statistics such as mean, standard deviation, and median.

Usage

descriptive.statistics(
  data,
  vars = NULL,
  groups = NULL,
  use.labels = T,
  digits = 4
)

Arguments

data

A data frame containing the variables for which descriptive statistics should be calculated.

vars

A character vector or symbol specifying the variables for which descriptive statistics will be computed. If NULL, all variables in the data frame will be used.

groups

A character vector or symbol specifying one or more grouping variables. If NULL, no grouping will be performed.

use.labels

A logical value indicating whether to use variable labels. Default is TRUE.

digits

An integer specifying the number of decimal places to round the numeric results. Default is 4.

Value

A data frame containing the descriptive statistics for the specified variables.

Examples

# Load example dataset
data(mtcars)

# Get descriptive statistics for all variables
descriptive.statistics(mtcars)

# Get descriptive statistics for specific variables grouped by a factor
descriptive.statistics(mtcars, vars = c("mpg", "hp"), groups = "cyl")


DiogoFerrari/edar documentation built on Dec. 1, 2024, 10:47 p.m.