View source: R/compute_quantiles.R
compute_quantiles | R Documentation |
compute quantiles of data across categories
compute_quantiles(sim_panel_data, quantile_prob = seq(0.01, 0.99, 0.01))
sim_panel_data |
data with categories and response variable |
quantile_prob |
quantiles of reponse variable needed |
data with quantiles of response variable corresponding to categories
Sayani07
library(ggplot2) library(dplyr) library(distributional) library(tidyr) sim_panel_data <- sim_panel( nx = 3, nfacet = 2, ntimes = 100, sim_dist = distributional ::dist_normal(5, 10) ) %>% unnest(c(data)) sim_panel_data %>% ggplot() + geom_boxplot(aes(x = as.factor(id_x), y = sim_data)) + facet_wrap(~id_facet) compute_quantiles(sim_panel_data) %>% unnest(sim_data_quantile) %>% ggplot() + geom_boxplot(aes(x = as.factor(id_x), y = unlist(sim_data_quantile))) + facet_wrap(~id_facet) sim_varx_normal <- function(nx, nfacet, mean, sd, w) { rep(dist_normal((mean + seq(0, nx - 1, by = 1) * w), sd), nfacet) } data <- sim_panel( nx = 3, nfacet = 2, ntimes = 100, sim_dist = sim_varx_normal(nx = 3, nfacet = 2, mean = 0, sd = 1, w = 100) ) sim_panel_data %>% ggplot() + geom_boxplot(aes(x = as.factor(id_x), y = sim_data)) + facet_wrap(~id_facet) compute_quantiles(sim_panel_data) %>% unnest(sim_data_quantile) %>% ggplot() + geom_boxplot(aes(x = as.factor(id_x), y = unlist(sim_data_quantile))) + facet_wrap(~id_facet)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.