insert_named

0th

Percentile

Insert or Remove Named Elements

Insert elements from y into x by name, or remove elements from x by name. Works for vectors, lists, environments and data frames and data tables. Objects with reference semantic (environment() and data.table::data.table()) might be modified in-place.

Usage
insert_named(x, y)

# S3 method for default insert_named(x, y)

# S3 method for environment insert_named(x, y)

# S3 method for data.frame insert_named(x, y)

# S3 method for data.table insert_named(x, y)

remove_named(x, nn)

# S3 method for environment remove_named(x, nn)

# S3 method for data.frame remove_named(x, nn)

# S3 method for data.table remove_named(x, nn)

Arguments
x

:: (vector() | list() | environment() | data.table::data.table()) Object to insert elements into, or remove elements from. Changes are by-reference for environments and data tables.

y

:: list() List of elements to insert into x.

nn

:: character() Character vector of elements to remove.

Value

Modified object.

Aliases
  • insert_named
  • insert_named.default
  • insert_named.environment
  • insert_named.data.frame
  • insert_named.data.table
  • remove_named
  • remove_named.environment
  • remove_named.data.frame
  • remove_named.data.table
Examples
# NOT RUN {
x = list(a = 1, b = 2)
insert_named(x, list(b = 3, c = 4))
remove_named(x, "b")
# }
Documentation reproduced from package mlr3misc, version 0.1.0, License: LGPL-3

Community examples

Looks like there are no examples yet.