set_key_value.RdThis function adds or updates a key-value pair in a data frame. If the key already exists in the data frame, its value is updated. If the key does not exist, a new row is added with the specified key and value.
set_key_value(x, key_name, value)A data frame with the updated or newly added key-value pair. If `x` was `NULL`, a new data frame is returned.
# Create an empty data frame and add a key-value pair
df <- NULL
df <- set_key_value(df, "name", "Alice")
# Update the value for an existing key
df <- set_key_value(df, "name", "Bob")
# Add another key-value pair
df <- set_key_value(df, "age", "30")