percentify: Group a data.frame by percentile ranges in variable

Description Usage Arguments Details Value See Also Examples

View source: R/percentify.R

Description

percentify() is the main function in percentify. It takes a data.frame or tibble, and creates groups based on the quantiles lower and upper bounds specified. This become handy once you start working with multiple overlapping bounds.

Usage

1
2
3
autoplot.percentiled_df(object)

percentify(data, var, lower = 0, upper = 1, key = ".percentile")

Arguments

object

The percentiled_df data frame returned from any percentify functions.

data

A data.frame or tibble,

var

Variable to do grouping by as string or symbol.

lower

Numerical values for lower bound of ranges. Must be between 0 and 1. Length of lower and upper must be equal.

upper

Numerical values for upper bound of ranges. Must be between 0 and 1. Length of lower and upper must be equal.

key

A single character specifying the name of the virtual group that is added. Defaults to ".percentile".

Details

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

Value

percentile grouped tibble

See Also

Other percentile samplers: percentify_cut, percentify_max, percentify_min, percentify_random

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
library(dplyr)
library(broom)
percent_mtcars <- percentify(mtcars, mpg,
                             lower = c(0.2, 0.4),
                             upper = c(0.6, 0.8)
                             )

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.