Produce a data frame to summaries continuous variables
continuous_table.Rd
Takes a data frame and produces grouped or un-grouped summaries such as mean and standard deviation for continuous variables.
Usage
continuous_table(
df = .,
...,
group = .,
time = .,
total = TRUE,
digits = 2,
condense = FALSE
)
Arguments
- df
Data frame
- ...
Variables to be summarised
- group
Optional variable that defines the grouping
- time
Optional variable for repeated measures (currently must me used with group)
- total
Logical indicating whether a total column should be created
- digits
Number of digits to the right of the decimal point
- condense
should the
variable
andscoring
columns in the output be condensed to one column?
Examples
continuous_table(df = iris, Petal.Length, Petal.Width, group = Species)
#> # A tibble: 9 × 6
#> variable scoring Total setosa versicolor virginica
#> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 NA NA N = 150 N = 50 N = 50 N = 50
#> 2 Petal.Length n 150 50 50 50
#> 3 Petal.Length Mean (SD) 3.76 (1.77) 1.46 (0.17) 4.26 (0.4… 5.55 (0.…
#> 4 Petal.Length Median (IQR) 4.35 (1.60, 5.10) 1.50 (1.40, … 4.35 (4.0… 5.55 (5.…
#> 5 Petal.Length Min, Max 1, 6.9 1, 1.9 3, 5.1 4.5, 6.9
#> 6 Petal.Width n 150 50 50 50
#> 7 Petal.Width Mean (SD) 1.20 (0.76) 0.25 (0.11) 1.33 (0.2… 2.03 (0.…
#> 8 Petal.Width Median (IQR) 1.30 (0.30, 1.80) 0.20 (0.20, … 1.30 (1.2… 2.00 (1.…
#> 9 Petal.Width Min, Max 0.1, 2.5 0.1, 0.6 1, 1.8 1.4, 2.5
continuous_table(df = iris, Sepal.Length, Sepal.Width, group = Species,
total = FALSE)
#> # A tibble: 9 × 5
#> variable scoring setosa versicolor virginica
#> <chr> <chr> <chr> <chr> <chr>
#> 1 NA NA N = 50 N = 50 N = 50
#> 2 Sepal.Length n 50 50 50
#> 3 Sepal.Length Mean (SD) 5.01 (0.35) 5.94 (0.52) 6.59 (0.64)
#> 4 Sepal.Length Median (IQR) 5.00 (4.80, 5.20) 5.90 (5.60, 6.30) 6.50 (6.23, 6.9…
#> 5 Sepal.Length Min, Max 4.3, 5.8 4.9, 7 4.9, 7.9
#> 6 Sepal.Width n 50 50 50
#> 7 Sepal.Width Mean (SD) 3.43 (0.38) 2.77 (0.31) 2.97 (0.32)
#> 8 Sepal.Width Median (IQR) 3.40 (3.20, 3.68) 2.80 (2.52, 3.00) 3.00 (2.80, 3.1…
#> 9 Sepal.Width Min, Max 2.3, 4.4 2, 3.4 2.2, 3.8
continuous_table(df = iris, Petal.Length, Sepal.Length, digits = 1)
#> # A tibble: 9 × 3
#> variable scoring value
#> <chr> <chr> <chr>
#> 1 NA NA N = 150
#> 2 Petal.Length n 150
#> 3 Petal.Length Mean (SD) 3.8 (1.8)
#> 4 Petal.Length Median (IQR) 4.3 (1.6, 5.1)
#> 5 Petal.Length Min, Max 1, 6.9
#> 6 Sepal.Length n 150
#> 7 Sepal.Length Mean (SD) 5.8 (0.8)
#> 8 Sepal.Length Median (IQR) 5.8 (5.1, 6.4)
#> 9 Sepal.Length Min, Max 4.3, 7.9