squishList: Compress a List by Name

Description Usage Arguments Details Value Author(s) Examples

View source: R/squishList.R

Description

Attempts to compress a list by combining elements with the same name, searching recursively if there are lists in your list

Usage

1
squishList(myList)

Arguments

myList

a list with named elements to be compressed

Details

items with the same name are assumed to have the same structure and will be combined. Dataframes will be combined with bind_rows, vectors just be collapsed into one vector, matrices will be combined with rbind, lists will be combined recursively with another call to squishList

Value

a list with one element for every unique name in the original list

Author(s)

Taiki Sakai taiki.sakai@noaa.gov

Examples

1
2
3
4
5
6
7
8
myList <- list(a=1:3, b=letters[1:4], a=5:6, b=letters[4:10])
squishList(myList)

myList <- list(a=1:3, b=data.frame(x=1:3, y=4:6), b=data.frame(x=10:14, y=1:5))
squishList(myList)

myList <- list(a=list(c=1:2, d=2), b=letters[1:3], a=list(c=4:5, d=6:9))
squishList(myList)

PAMmisc documentation built on Oct. 8, 2021, 9:08 a.m.