keys_near.data.frame: Return keys nearest to a given statistics or summary.

View source: R/keys_near.R

keys_near.data.frameR Documentation

Return keys nearest to a given statistics or summary.

Description

Return keys nearest to a given statistics or summary.

Usage

## S3 method for class 'data.frame'
keys_near(.data, key, var, top_n = 1, funs = l_five_num, ...)

Arguments

.data

data.frame

key

key, which identifies unique observations.

var

variable to summarise

top_n

top number of closest observations to return - default is 1, which will also return ties.

funs

named list of functions to summarise by. Default is a given list of the five number summary, l_five_num.

...

extra arguments to pass to mutate_at when performing the summary as given by funs.

Examples

heights %>%
  key_slope(height_cm ~ year) %>%
  keys_near(key = country,
            var = .slope_year)
# Specify your own list of summaries
l_ranges <- list(min = b_min,
                 range_diff = b_range_diff,
                 max = b_max,
                 iqr = b_iqr)

heights %>%
  key_slope(formula = height_cm ~ year) %>%
  keys_near(key = country,
              var = .slope_year,
              funs = l_ranges)

brolgar documentation built on Feb. 16, 2023, 7:49 p.m.