dlapply: Lapply-like function for data list objects

View source: R/data_list.R

dlapplyR Documentation

Lapply-like function for data list objects

Description

This function enables manipulating a data_list class object with lapply syntax without removing that object's data_list class attribute. The function will only preserve this attribute if the result of the apply call has a valid data list structure.

Usage

dlapply(X, FUN, ...)

Arguments

X

A data_list class object.

FUN

The function to be applied to each data list component.

...

Optional arguments to FUN.

Value

If FUN applied to each component of X yields a valid data list, a data list. Otherwise, a list.

Examples

# Convert all UID values to lowercase
dl <- data_list(
    list(abcd_income, "income", "demographics", "discrete"),
    list(abcd_colour, "colour", "likes", "categorical"),
    uid = "patient"
)

dl_lower <- dlapply(
    dl,
    function(x) {
        x$"data"$"uid" <- tolower(x$"data"$"uid")
        return(x)
    }
)

metasnf documentation built on April 3, 2025, 5:40 p.m.