to_map: Generalizes functions to work on lists of data

Description Usage Arguments Value Examples

View source: R/to_map.R

Description

Generalizes functions to work on lists of data

Usage

1
to_map(func)

Arguments

func

A function

Value

A function that works on lists of data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
setwd("path/to/datasets/")
list_of_datasets <- list.files(pattern = "*.csv")
list_of_loaded_datasets <- read_list(list_of_datasets, read_func = read.csv)
# To get the summary statistics of all variables for all the datasets in the list:
summarymap <- to_map(summary)
summarymap(list_of_loaded_datasets)
# To get the summary statistics of a single variable for all the datasets in the list:
summarymap(list_of_loaded_datasets, "variable")
# This is equivalent to
purrr::map(list_of_loaded_datasets, (function(x) summary(x$variable)))

## End(Not run)

b-rodrigues/brotools documentation built on April 21, 2020, 2:27 p.m.