This function computes common descriptive statistics of numeric variables for grouped or ungrouped data and converts it to a tidy formatted table. This function tried to copy dlookr::describe() because of this issue.

describe(
  data,
  yvars,
  lang = c("eng", "ger")[1],
  ungroupafter = TRUE,
  digits = "round_smart",
  addstats = character(),
  ...
)

Arguments

data

A data.frame or a tbl_df or a grouped_df.

yvars

A character vector with the names of the columns to be described.

lang

Language for table names.

ungroupafter

If TRUE, the results will be ungroup()-ed.

digits

Number of digits all numeric columns are rounded to. The default is actually "round_smart" which applies BioMathR::round_smart() to each numeric column individually.

addstats

Character vector with additional statistics to be calculated besides the default. Possible entries: c("Skewness").

...

Other arguments passed to BioMathR::round_smart()

Value

A tibble

Examples

library(dplyr)
library(BioMathR)
PlantGrowth %>%
  group_by(group) %>%
  describe("weight")
#> # A tibble: 3 × 10
#>   Variable group     N  Miss  Mean StdDev   IQR   Min Median   Max
#>   <chr>    <fct> <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl>  <dbl> <dbl>
#> 1 weight   ctrl     10     0  5.03    0.6   0.7   4.2    5.2  6.11
#> 2 weight   trt1     10     0  4.66    0.8   0.7   3.6    4.6  6.03
#> 3 weight   trt2     10     0  5.53    0.4   0.5   4.9    5.4  6.31

PlantGrowth %>%
  mutate(
    group2 = as.factor(rep(c("A", "A", "B",  "B", "B"), 6)),
    weight2 = weight * 2,
    weight3 = rep(c(3, NA), 15)
  ) %>%
  group_by(group, group2) %>%
  describe(c("weight", "weight2", "weight3"), lang = "ger") %>%
  docx_tab()

Variable

group

group2

N

Fehl

MW

StdAbw

IQA

Min

Median

Max

weight

ctrl

A

4

0

4.9

0.6

0.80

4.2

4.90

5.60

weight

ctrl

B

6

0

5.1

0.6

0.60

4.5

5.20

6.10

weight

trt1

A

4

0

4.7

1.0

1.03

3.8

4.50

6.03

weight

trt1

B

6

0

4.6

0.8

0.50

3.6

4.60

5.87

weight

trt2

A

4

0

5.4

0.6

0.50

4.9

5.20

6.30

weight

trt2

B

6

0

5.6

0.3

0.30

5.3

5.52

6.10

weight2

ctrl

A

4

0

9.8

1.2

1.50

8.3

9.80

11.20

weight2

ctrl

B

6

0

10.3

1.2

1.20

9.0

10.30

12.20

weight2

trt1

A

4

0

9.4

1.9

2.06

7.7

9.00

12.06

weight2

trt1

B

6

0

9.3

1.5

0.99

7.2

9.10

11.74

weight2

trt2

A

4

0

10.8

1.2

0.90

9.8

10.41

12.60

weight2

trt2

B

6

0

11.2

0.6

0.70

10.5

11.04

12.30

weight3

ctrl

A

2

2

3.0

0.0

0.00

3.0

3.00

3.00

weight3

ctrl

B

3

3

3.0

0.0

0.00

3.0

3.00

3.00

weight3

trt1

A

2

2

3.0

0.0

0.00

3.0

3.00

3.00

weight3

trt1

B

3

3

3.0

0.0

0.00

3.0

3.00

3.00

weight3

trt2

A

2

2

3.0

0.0

0.00

3.0

3.00

3.00

weight3

trt2

B

3

3

3.0

0.0

0.00

3.0

3.00

3.00