Package 'roomba'

Title: Tidy up nested list hairballs
Description: This is a package to transform large, multi-nested lists into a more user-friendly format. The initial focus is on making processing of return values from `jsonlite::fromJSON()` queries more seamless, but ideally this package should be useful for deeply-nested lists from an array of sources.
Authors: Amanda Dobbyn [aut], Christine Stawitz [aut], Isabella Velasquez [aut], Jim Hester [aut, cre], Laura DeCicco [aut]
Maintainer: Jim Hester <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2024-11-02 02:42:26 UTC
Source: https://github.com/cstawitz/roomba

Help Index


roomba package

Description

Package: roomba
Type: Package

Details

Collection of functions to do deal with deeply nested data


Perform a recursive depth first search of a function

Description

Perform a recursive depth first search of a function

Usage

dfs_idx(.x, .f)

Arguments

.x

A list or atomic vector.

.f

A function, formula, or atomic vector.

If a function, it is used as is.

If a formula, e.g. ~ .x + 2, it is converted to a function. There are three ways to refer to the arguments:

  • For a single argument function, use .

  • For a two argument function, use .x and .y

  • For more arguments, use ..1, ..2, ..3 etc

This syntax allows you to create very compact anonymous functions.

If character vector, numeric vector, or list, it is converted to an extractor function. Character vectors index by name and numeric vectors index by position; use a list to index by position and name at different levels. Within a list, wrap strings in get-attr() to extract named attributes. If a component is not present, the value of .default will be returned.


List all names in a list

Description

List all names in a list

Usage

list_names(x)

Arguments

x

list to use


Example data from reddit

Description

Example data from reddit

Usage

reddit

Format

An object of class list of length 2.

Source

https://www.reddit.com/dev/api/


Replace NULLs

Description

Replace all the empty values in a list

Usage

replace_null(x, replacement = NA)

Arguments

x

list to use

replacement

Replacement value for missing values

Examples

list(a = NULL, b = 1, c = list(foo = NULL, bar = NULL)) %>% replace_null()

Roomba

Description

Tidy your nested list

Usage

roomba(inp, cols = NULL, default = NA, keep = all)

Arguments

inp

List to tidy

cols

Columns to keep

default

Replacement for NULL values. Defaults to NA.

keep

Should all or any data be kept?

Examples

simple %>% roomba(cols = c("name", "goodstuff"), keep = any)
simple %>% roomba(cols = c("name", "goodstuff"), keep = any)

Run the roomba app

Description

Run the roomba app

Usage

shiny_roomba(browse = TRUE)

Arguments

browse

Logical. Use browser for running Shiny app.

Examples

## Not run: 
if(require(shiny)){
   shiny_roomba()
}

## End(Not run)

Example data with simple nested list

Description

Example data with simple nested list

Usage

simple

Format

An object of class character of length 1.


Example Twitter data

Description

Example data from Twitter API

Usage

twitter_data

Format

An object of class list of length 20.

Details

twitter_data[[1]][["id"]]

[[1]: R:[1 ["id"]: R:

Source

https://developer.twitter.com/en/docs


Example data from vimeo

Description

Example data from vimeo

Usage

vimeo

Format

An object of class response of length 10.

Source

https://developer.vimeo.com/