Learn R Programming

SpaDES (version 1.2.0)

append_attr: 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)
"append_attr"(x, y)

Arguments

x
A list of items with optional attributes.
y
See x.

Value

An updated list with attributes.

Details

Similar to updateList but does not require named lists.

Examples

Run this code
library(igraph) # igraph exports magrittr's pipe operator
tmp1 <- list("apple", "banana") %>% lapply(., `attributes<-`, list(type = "fruit"))
tmp2 <- list("carrot") %>% lapply(., `attributes<-`, list(type = "vegetable"))
append_attr(tmp1, tmp2)
rm(tmp1, tmp2)

Run the code above in your browser using DataLab