vec_segment | R Documentation |
Calculate vector's standard derivation, standard error of mean and confidence interval.
vec_segment(x, bar = c("SD", "SE", "CI"))
x |
an vector. |
bar |
a character string, supporting "SD", "SE" and "CI". |
an vector including lower, center and upper values.
Other vector stats functions:
vec_stats()
library(plyr)
library(reshape2)
library(dplyr)
library(tidyr)
library(purrr)
vec_segment(iris[,1])
## Use 'plyr' and 'reshape2' for group
mat <- melt(iris)
ddply(mat, .(Species,variable), function(x,bar) {
vec_segment(x$value, bar = bar)
}, bar = "SD")
## Use 'tidyverse' for group
iris %>%
pivot_longer(cols = !Species, names_to = "variable") %>%
group_by(Species, variable) %>%
nest() %>%
mutate(map_dfr(.x = data, .f = ~ vec_segment(.x$value))) %>%
select(!data)
iris %>%
pivot_longer(cols = !Species, names_to = "variable") %>%
group_nest(Species, variable) %>%
mutate(map_dfr(data, ~ vec_segment(.x$value))) %>%
select(!data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.