filter_by_funs: Filter a data frame accoring to descriptive functions

Description Usage Arguments Value Examples

View source: R/filter_by_funs.R

Description

This function allows you to subset a data frame by any set of descriptive statistics. For example, you could extract rows that are eqaul to specific quantiles, or the min and the max. This is a dplyr-like function, and works well with functions such as group_by.

Usage

1
filter_by_funs(data, variable, .funs)

Arguments

data

The data frame that includes the variables to compute descriptive statistics on.

variable

The variable to filter on.

.funs

The functions to use in filtering.

Value

A tidy data frame with the requested descriptive statistics for the requested variables

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(dplyr)
storms %>%
 filter_by_funs(wind, funs(min,
                           quantile(., .25, na.rm = TRUE),
                           quantile(., .50, na.rm = TRUE),
                           quantile(., .75, na.rm = TRUE),
                           max))
storms %>%
  group_by(year) %>%
  filter_by_funs(wind, funs(min,max)) %>%
  arrange(year)

datalorax/sundry documentation built on April 11, 2021, 1:50 p.m.