Description Usage Arguments Value Author(s) Examples
View source: R/compute_quantiles.R
compute quantiles of data across categories
1 | 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | library(ggplot2)
library(tidyverse)
library(distributional)
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.