summarize_numeric: Produce Summary Tables for Data Sets

Description Usage Arguments Value Author(s) See Also Examples

View source: R/summarize.R

Description

The function produces summary tables for continuous variables. The obtained tables can be used directly in R, with LaTeX and HTML (by using the xtable function) or Markdown (e.g. by using the function kable).

Usage

1
2
3
4
5
6
7
8
9
summarize_numeric(data,
    variables = names(data), variable.labels = labels, labels = NULL,
    group = NULL, test = !is.null(group), colnames = NULL,
    digits = 2, digits.pval = 3, smallest.pval = 0.001,
    sep = !is.null(group), sanitize = TRUE,
    drop = TRUE, show.NAs = any(is.na(data[, variables])),
    ## additional specific arguments
    count = TRUE, mean_sd = TRUE, quantiles = TRUE,
    incl_outliers = TRUE, ...)

Arguments

data

data set to be used.

variables

variables that should be included in the table. For details see summarize.

variable.labels, labels

labels for the variables. For details see summarize.

group

character specifying a grouping factor. For details see summarize.

test

logical or charachter specifying test for group differences. For details see summarize.

colnames

a vector of character strings of appropriate length. For details see summarize.

digits

number of digits to round to. Per default all values are rounded to two digits.

digits.pval

number of significant digits used for p-values.

smallest.pval

determines the smallest p-value to be printed exactly. For details see summarize.

sep

logical (default: TRUE if grouping specified, FALSE otherwise). Determines whether separators (lines) should be added after each variable.

sanitize

logical (default: TRUE) or a sanitizing function. For details see summarize.

drop

logical (default: TRUE). Determines whether variables, which contain only missing values are dropped from the table.

show.NAs

logical. Determines if the number of missings (NAs) is displayed as a separate column. Per default, show.NAs is TRUE if there are any missings in the variables to be displayed (and FALSE if not).

count

(logical) indicator if number of complete cases ("n") should be included in the table (default: TRUE).

mean_sd

(logical) indicator if mean and standard deviation should be included in the table (default: TRUE).

quantiles

(logical) indicator if quantiles (including min and max) should be included in the table (default: TRUE).

incl_outliers

Per default we use fivenum to compute the quantiles (if quantiles = TRUE). If extreme values should be excluded from min/max in the table, boxplot( , plot = FALSE)$stats is used instead.

...

additional arguments. Currently not used.

Value

A special data.frame with additional class summary containing the computed statistics is returned from function summarize. Addtional attributes required for the xtable.summary or print.xtable.summary function are contained as attributes. These are extracted using the function get_option.

Author(s)

Benjamin Hofner

See Also

For details see link{summarize} and link{summarize_factor}.

Conversion to LaTeX tables can be done using xtable.summary and print.xtable.summary.

get_option

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
if (require("nlme")) {
    ## Use dataset Orthodont
    data(Orthodont, package = "nlme")

    ## Get summary for continuous variables
    summarize(Orthodont, type = "numeric")

    ## Change statistics to display
    summarize(Orthodont, quantiles = FALSE, type = "numeric")
    summarize(Orthodont, quantiles = FALSE, count = FALSE, type = "numeric")
    summarize(Orthodont, mean_sd = FALSE, type = "numeric")

    ## for more examples see ?summarize
}

Example output

Loading required package: car
Loading required package: carData
Loading required package: xtable

Attaching package: 'papeR'

The following object is masked from 'package:utils':

    toLatex

Loading required package: nlme
Factors are dropped from the summary
Factors are dropped from the summary
Factors are dropped from the summary
Factors are dropped from the summary
             N    Min Q1 Median Q3  Max
1 distance 108   16.5 22  23.75 26 31.5
2      age 108    8.0  9  11.00 13 14.0

papeR documentation built on March 23, 2021, 1:08 a.m.