qtiledf: Get quantiles and number of not-NA observations for a vector,...

View source: R/btools_dplyrtools.r

qtiledfR Documentation

Get quantiles and number of not-NA observations for a vector, return as tibble

Description

qtiledf get quantiles and number of not-NA observations for a vector, return as data frame

Usage

qtiledf(vec, probs)

Arguments

vec

Numeric vector. No default.

probs

Numeric vector of quantiles. Default is c(0, .1, .25, .5, .75, .9, 1).

Details

Very little error checking. Useful after dplyr's group_by, in do command, which requires data frame input.

Value

Data frame with columns as quantiles

Examples

library(dplyr)
df <- tibble(year=c(rep(1, 5), rep(2, 7)), x=c(seq(1, 2, length.out=11), NA))
df
df %>%
  group_by(year) %>%
  summarise(qtiledf(.$x, c(.1, .25, .5, .75, .9)))

donboyd5/btools documentation built on Jan. 7, 2023, 10:47 p.m.