sample_sizes: Creates table with sample sizes and attrition rates

View source: R/sample_sizes.r

sample_sizesR Documentation

Creates table with sample sizes and attrition rates

Description

This functions binds individual numeric values (representing sample sizes) into a printable table. It is a follow-up function for save_n which extracts the number of cases in a data frame.

Usage

sample_sizes(..., sample = c("All cases", "Eligible cases",
  "Complete cases"), digits = 1, print = FALSE)

Arguments

...

Several numeric values representing sample sizes (e.g., obtained by using save_n).

sample

Names for the rows in the final table.

digits

Number of digits that should be print (only in combination with print = TRUE).

print

Logical value indicating whether the output should be formatted to fit APA-guidelines (transform varibales to character vectors).

Value

An object of class tbl_df that can be passed to apa_table. It contains all sample sizes that were provided as individual numeric values.

Examples

# Simple example
sample_sizes(100, 80, 10, print = TRUE)

# Realistic example
d <- mtcars
d1 <- d[1:28,]
d2 <- d1[1:20,]

n0 <- save_n(d)
n1 <- save_n(d1)
n2 <- save_n(d2)

sample_sizes(n0, n1, n2)
sample_sizes(n0, n1, n2, 
             sample = c("Sample 1", 
                        "Sample 2",
                        "Sample 3"),
             digits = 3,
             print = TRUE)

masurp/pmmisc documentation built on May 3, 2024, 7:13 p.m.