collapse_group_row: Replace repeated rows in a data.frame with NA

View source: R/collapse_group_row.R

collapse_group_rowR Documentation

Replace repeated rows in a data.frame with NA

Description

This function is for replacing repeated rows in a data.frame into NA for nice printing. This is not intended for use during processing.

Usage

collapse_group_row(.data, ..., reorder_cols = TRUE)

Arguments

.data

a data.frame

...

Columns to use to identify which to rows to replace with NA's

reorder_cols

if TRUE will order columns listed in ... first

Value

a data.frame where repeated rows in the columns identified by ... are replaced with NA

Examples

sample_df <- data.frame(
  x = c(1, 1, 1, 2, 2, 2, 2),
  y = c('test1', 'test1', 'test2', 'test1', 'test2', 'test2', 'test1'),
  z = c(1, 2, 3, 4, 5, 6, 7),
  outputVal = runif(7)
)

library(dplyr)
options(knitr.kable.NA = '')
collapse_group_row(sample_df, x, y, z) %>%
 kableExtra::kable() %>%
 kableExtra::kable_styling()

FredHutch/VISCfunctions documentation built on Oct. 14, 2024, 11:33 p.m.