summarize_metrics: Summarize metrics with common descriptors

Description Usage Arguments Value Author(s) Examples

View source: R/summarize_metrics.R

Description

\Sexpr[results=rd, stage=render]{lifecycle::badge("experimental")}

Summarizes all numeric columns. Counts the NAs and Infs in the columns.

Usage

1
summarize_metrics(data, cols = NULL, na.rm = TRUE, inf.rm = TRUE)

Arguments

data

data.frame with numeric columns to summarize.

cols

Names of columns to summarize. Non-numeric columns are ignored. (Character)

na.rm

Whether to remove NAs before summarizing. (Logical)

inf.rm

Whether to remove Infs before summarizing. (Logical)

Value

tibble where each row is a descriptor of the column.

The Measure column contains the name of the descriptor.

The NAs row is a count of the NAs in the column.

The INFs row is a count of the Infs in the column.

Author(s)

Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Attach packages
library(cvms)
library(dplyr)

df <- data.frame("a" = c("a", "a", "a", "b", "b", "b", "c", "c", "c"),
                 "b" = c(0.8, 0.6, 0.3, 0.2, 0.4, 0.5, 0.8, 0.1, 0.5),
                 "c" = c(0.2, 0.3, 0.4, 0.6, 0.5, 0.8, 0.1, 0.8, 0.3))

# Summarize all numeric columns
summarize_metrics(df)

# Summarize column "b"
summarize_metrics(df, cols = "b")

Example output

Attaching package:dplyrThe following objects are masked frompackage:stats:

    filter, lag

The following objects are masked frompackage:base:

    intersect, setdiff, setequal, union

# A tibble: 8 x 3
  Measure     b     c
  <chr>   <dbl> <dbl>
1 Mean    0.467 0.444
2 Median  0.5   0.4  
3 SD      0.245 0.251
4 IQR     0.3   0.3  
5 Max     0.8   0.8  
6 Min     0.1   0.1  
7 NAs     0     0    
8 INFs    0     0    
# A tibble: 8 x 2
  Measure     b
  <chr>   <dbl>
1 Mean    0.467
2 Median  0.5  
3 SD      0.245
4 IQR     0.3  
5 Max     0.8  
6 Min     0.1  
7 NAs     0    
8 INFs    0    

cvms documentation built on June 17, 2021, 5:12 p.m.