Learn R Programming

cohortBuilder (version 0.3.0)

.get_item: Return list of objects matching provided condition.

Description

Return list of objects matching provided condition.

Usage

.get_item(list_obj, attribute, value, operator = `==`)

Value

A subset of list object matching provided condition.

Arguments

list_obj

List of R objects.

attribute

Object attribute name.

value

Object value.

operator

Logical operator - two-argument function taking `list_obj` attribute value as the first one, and `value` as the second one.

Examples

Run this code
my_list <- list(
  list(id = 1, name = "a"),
  list(id = 2, name = "b")
)
.get_item(my_list, "id", 1)
.get_item(my_list, "name", c("b", "c"), identical)

Run the code above in your browser using DataLab