vec_stats: Vector summary

View source: R/mt_extra_1.R

vec_statsR Documentation

Vector summary

Description

Calculate the statistical summary of a vector.

Usage

vec_stats(x, na.rm = FALSE, conf.interval = 0.95)

Arguments

x

a numeric vector.

na.rm

remove NA or not.

conf.interval

a numeric value for confidence interval.

Details

Can be used for error bar plotting. Modify from https://bit.ly/3onsqot

Value

a vector of summary consisting:

  • number of vector length

  • vector mean

  • vector standard derivation

  • standard error of mean

  • confidence interval

See Also

Other vector stats functions: vec_segment()

Examples

 
library(dplyr)
library(tidyr)
library(purrr)

iris %>% dat_summ(method = vec_stats)
iris %>% group_by(Species) %>% group_modify(~ dat_summ(., method = vec_stats))
iris %>%
  pivot_longer(cols = !Species, names_to = "var") %>% 
  group_nest(Species, var) %>%
  mutate(map_dfr(data, ~ vec_stats(.x$value))) %>%
  select(!data)

wanchanglin/mtExtra documentation built on Aug. 2, 2024, 5:47 p.m.