append_attr: Add a module to a 'moduleList'

append_attrR Documentation

Add a module to a moduleList

Description

Ordinary base lists and vectors do not retain their attributes when subsetted or appended. This function appends items to a list while preserving the attributes of items in the list (but not of the list itself).

Usage

append_attr(x, y)

## S4 method for signature 'list,list'
append_attr(x, y)

Arguments

x, y

A list of items with optional attributes.

Details

Similar to updateList but does not require named lists.

Value

An updated list with attributes.

Author(s)

Alex Chubaty and Eliot McIntire

Examples

tmp1 <- list("apple", "banana")
tmp1 <- lapply(tmp1, `attributes<-`, list(type = "fruit"))
tmp2 <- list("carrot")
tmp2 <- lapply(tmp2, `attributes<-`, list(type = "vegetable"))
append_attr(tmp1, tmp2)
rm(tmp1, tmp2)

PredictiveEcology/SpaDES.core documentation built on April 17, 2024, 8:27 a.m.