modify: Modify a Toml object

remove_itemsR Documentation

Modify a Toml object

Description

remove_items() removes one or more items from the TOML document. Alternatively, insert_items() inserts key value pairs into the TOML document.

Usage

remove_items(x, keys)

insert_items(x, ..., df_as_array = TRUE)

get_item(x, key)

Arguments

x

an object of class Toml.

keys

a character vector of key names to remove. Cannot contain missing values.

...

named items to be serialized to TOML.

df_as_array

default TRUE. Creates an array of tables from a data.frame. When FALSE, creates a single table with an array for each column in the data.frame.

key

a character vector of key values. The keys are used recursively. For example with key = c("a", "b") the item a is grabbed first, then b is searched for inside of a.

Value

an object of class Toml

Examples

x <- toml(
  date = list(
    full = as.Date("2025-02-07"),
    parts = list(year = 2015L, month = "February", day = 7L)
  ),
  season = "winter"
)

# fetch the date table
get_item(x, "date")

# fetch the month value
get_item(x, c("date", "parts", "month"))

# remove an item based on name
remove_items(x, "season")

# add multiple items
insert_items(x, temperature = 31, cloudy = TRUE)

tomledit documentation built on April 11, 2025, 6:14 p.m.