fasten {cheese}R Documentation

Bind a list of data frames back together

Description

Roll up a list of arbitrary depth with data.frame's at the leaves row-wise.

Usage

fasten(
    list,
    into = NULL,
    depth = 0
)

Arguments

list

A list with data.frame's at the leaves.

into

A character vector of resulting column names. Defaults to NULL.

depth

Depth to bind the list to. Defaults to 0.

Details

Use empty strings "" in the into argument to omit column creation when rows are binded. Use positive integers for the depth to move from the root and negative integers to move from the leaves. The maximum (minimum) depth will be used for integers larger (smaller) than such. The leaves of the input list should be at the same depth.

Value

A tibble::tibble or reduced list

Author(s)

Alex Zajichek

Examples

#Make a divided data frame
list <-
  heart_disease %>%
  divide(
    Sex,
    HeartDisease,
    ChestPain
  )

#Bind without creating names
list %>% 
  fasten

#Bind with names
list %>% 
  fasten(
    into = c("Sex", "HeartDisease", "ChestPain")
  )

#Only retain "Sex"
list %>%
  fasten(
    into = "Sex"
  )

#Only retain "HeartDisease"
list %>%
  fasten(
    into = c("", "HeartDisease")
  )

#Bind up to Sex
list %>%
  fasten(
    into = c("HeartDisease", "ChestPain"),
    depth = 1
  )

#Same thing, but start at the leaves
list %>%
  fasten(
    into = c("HeartDisease", "ChestPain"),
    depth = -2
  )

#Too large of depth returns original list
list %>%
  fasten(
    depth = 100
  )

#Too small of depth goes to 0
list %>%
  fasten(
    depth = -100
  )

[Package cheese version 0.1.2 Index]