percentify_random: Group a data.frame by percentile ranges in variable with...

Description Usage Arguments Details Value See Also Examples

View source: R/percentify_random.R

Description

This function is a wrapper around percentify. Given a width`` and a n', it will generate a number of random interval with fixed width.

Usage

1

Arguments

data

A data.frame or tibble,

var

Variable to do grouping by as string or symbol.

width

Numerical values for the width of the interval. Must be between 0 and 1.

n

Integer, number of intervals to create.

Details

There is a ggplot2::autoplot() to visualize the the percentile ranges.

Value

percentile grouped tibble

See Also

Other percentile samplers: autoplot.percentiled_df, percentify_cut, percentify_max, percentify_min

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library(dplyr)
library(broom)
set.seed(1234)
percent_mtcars <- percentify_random(mtcars, mpg, 0.4, 10)

percent_mtcars

summarize(percent_mtcars,
          mean_hp = mean(hp),
          mean_wt = mean(wt),
          n_obs = n()
          )

percent_mtcars %>%
  group_modify(~tidy(lm(disp ~ wt + cyl, data = .x)))

library(ggplot2)
autoplot(percent_mtcars)

EmilHvitfeldt/percentify documentation built on July 9, 2019, 10:54 p.m.