knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

flatcat

Travis build status Codecov test coverage

The goal of flatcat is to provide flat map functions.

Installation

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("DavisVaughan/flatcat")

Examples

No size 1 restriction in each .f call

library(flatcat)
library(purrr)

map_dbl(list(1, 2:3, 4:6), ~.x)

flat_map_dbl(list(1, 2:3, 4:6), ~.x)

A neat (but fairly inefficient) way to interleave vectors

flat_map2_dbl(1:5, 6:10, ~c(.x, .y))

With data frames

flat_map_dfr(list(1, 2:3, 4:6), ~data.frame(x = .x))

flat_map_dfc(
  list(1, 2:3, 4, 5:6), 
  ~{
    name <- paste0("x_", paste0(.x, collapse = "_"))
    tibble::tibble(!! name := .x)
  }
)


DavisVaughan/flatcat documentation built on Oct. 30, 2019, 5 p.m.