combine_cases: Combine cases

View source: R/combine_cases.R

combine_casesR Documentation

Combine cases

Description

Groups .data by ... and applies .f to all other columns

Usage

combine_cases(.data, ..., .f)

Arguments

.data

A data frame

...

Unquoted grouping variables within .data

.f

A summary function. Defaults to first non-missing value

Value

a tbl

Author(s)

Sven Halvorson

Examples

## Not run: 
example_data = tibble(
  id = sample(letters, size = 100, replace = TRUE),
  bin = sample(0:1, size = 100, replace = TRUE),
  normal = rnorm(n = 100)
) %>%
  arrange(id, bin, normal)

example_data[2:ncol(example_data)] = lapply(
  example_data[2:ncol(example_data)],
  function(x){x[rnorm(length(x)) < -0.5] = NA;x}
)
combine_cases(
  .data = example_data,
  id
)

## End(Not run)

svenhalvorson/SvenR documentation built on Aug. 25, 2023, 1:31 p.m.