oppsum_grupp: Create a summary table for one variable grouped by another...

View source: R/oppsum_grupp.R

oppsum_gruppR Documentation

Create a summary table for one variable grouped by another variable

Description

This function allows you to create a table with summary statistics for one variable over groups defined by another variable. The table will show the following summary statistics: the number of nonmissing observations, the average (mean), the median, the 25th and 75th percentiles, the standard deviation, the minimum, the maximum, and the number of missing observations.

Usage

oppsum_grupp(dataset, variable, by.var, export = NULL, norsk = NULL)

Arguments

dataset

Your dataset (a data.frame-type object).

variable

The variable for which you want summary statistics (should ideally be a numeric variable).

by.var

The variable that defines the groups over which the statistics are calculated (should ideally be a categorical variable with not more than 10 unique categories).

export

Should the result be made export-ready (TRUE/FALSE)?

norsk

Results in Norwegian (NB)?

Details

The result can be printed in an "export-ready" fashion, meaning it can be copied and pasted into a Word document and there transformed into a publication-quality table. The function will provide warnings in some cases where user selections might be problematic.

Value

A data.frame or, if export function is switched on (export=TRUE), a printed out table formatted for easy export to MS Word.

Examples

## Not run: 
# Load mtcars
data(mtcars)

# Simple
oppsum_grupp(dataset = mtcars,
variable = "drat",
by.var = "gear")

# With export function
result <- oppsum_grupp(dataset = mtcars,
variable = "mpg",
by.var = "cyl",
export = TRUE)

## End(Not run)


cknotz/bst290 documentation built on Nov. 11, 2023, 1 p.m.