The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Type: Package
Title: Make Quick Descriptive Tables for Continuous Variables
Description: Quickly make tables of descriptive statistics (i.e., counts, means, confidence intervals) for continuous variables. This package is designed to work in a Tidyverse pipeline, and consideration has been given to get results from R to 'Microsoft Word' ® with minimal pain.
Version: 0.1.2
Maintainer: Brad Cannell <brad.cannell@gmail.com>
License: MIT + file LICENSE
Encoding: UTF-8
Suggests: knitr, rmarkdown, testthat
VignetteBuilder: knitr
RoxygenNote: 7.1.2
Imports: dplyr, tibble, rlang, stringr
NeedsCompilation: no
Packaged: 2022-03-19 21:35:49 UTC; bradcannell
Author: Brad Cannell [aut, cre, cph]
Repository: CRAN
Date/Publication: 2022-03-19 21:50:02 UTC

Format mean_table Output for Publication and Dissemination

Description

The mean_format function is intended to make it quick and easy to format the output of the mean_table function for tables that may be used for publication. For example, a mean and 95 could be formatted as "24.00 (21.00 - 27.00)."

Usage

mean_format(.data, recipe, name = NA, digits = NA)

Arguments

.data

A data frame of class "mean_table" or "mean_table_grouped".

recipe

A recipe used to create a new column from existing mean_table columns. The recipe must be in the form of a quoted string. It may contain any combination of column names, spaces, and characters. For example: "mean (sd)" or "mean (lcl - ucl)".

name

An optional name to assign to the column created by the recipe. The default name is "formatted_stats"

digits

The number of decimal places to display.

Value

A tibble

Examples

## Not run: 
library(dplyr)
library(meantables)

data(mtcars)

# Overall mean table with defaults

mtcars %>%
  mean_table(mpg) %>%
  mean_format("mean (sd)") %>%
  select(response_var, formatted_stats)

# A tibble: 1 × 2
  response_var formatted_stats
  <chr>        <chr>
1 mpg          20.09 (6.03)

# Grouped means table with defaults

mtcars %>%
  group_by(cyl) %>%
  mean_table(mpg) %>%
  mean_format("mean (sd)") %>%
  select(response_var:group_cat, formatted_stats)

  # A tibble: 3 × 4
  response_var group_var group_cat formatted_stats
  <chr>        <chr>         <dbl> <chr>
1 mpg          cyl               4 26.66 (4.51)
2 mpg          cyl               6 19.74 (1.45)
3 mpg          cyl               8 15.1 (2.56)

## End(Not run)

Estimate Mean and 95 Percent Confidence Intervals in dplyr Pipelines

Description

The mean_table function produces overall and grouped tables of means with related statistics. In addition to means, the mean_table missing/non-missing frequencies, the standard error of the mean (sem), the 95 value, and the maximum value. For grouped tibbles, mean_table displays these statistics for each category of the group_by variable.

Usage

mean_table(.data, .x, t_prob = 0.975, output = default, digits = 2, ...)

Arguments

.data

A tibble or grouped tibble.

.x

The continuous response variable for which the statistics are desired.

t_prob

(1 - alpha / 2). Default value is 0.975, which corresponds to an alpha of 0.05. Used to calculate a critical value from Student's t distribution with n - 1 degrees of freedom.

output

Options for this parameter are "default" and "all".

Default output includes the n, mean, sem, and 95 the mean. Using output = "all" also returns the the number of missing values for .x and the critical t-value.

digits

Round mean, lcl, and ucl to digits. Default is 2.

...

Other parameters to be passed on.

Value

A tibble of class "mean_table" or "mean_table_grouped"

References

SAS documentation: http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#p0klmrp4k89pz0n1p72t0clpavyx.htm

Examples

## Not run: 
library(dplyr)
library(meantables)

data(mtcars)

# Overall mean table with defaults

mtcars %>%
  mean_table(mpg)

# A tibble: 1 x 9
  response_var     n  mean    sd   sem   lcl   ucl   min   max
  <chr>        <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 mpg             32  20.1  6.03  1.07  17.9  22.3  10.4  33.9

# Grouped means table with defaults

mtcars %>%
  group_by(cyl) %>%
  mean_table(mpg)

# A tibble: 3 x 11
  response_var group_var group_cat     n  mean    sd   sem   lcl   ucl   min   max
  <chr>        <chr>         <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 mpg          cyl               4    11  26.7  4.51 1.36   23.6  29.7  21.4  33.9
2 mpg          cyl               6     7  19.7  1.45 0.549  18.4  21.1  17.8  21.4
3 mpg          cyl               8    14  15.1  2.56 0.684  13.6  16.6  10.4  19.2

## End(Not run)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.