Unified interface for getting, setting, and managing metadata in climasus_df objects. This single function replaces multiple accessor functions to keep the package namespace clean.
Usage
climasus_meta(
x = NULL,
field = NULL,
add_history = NULL,
print_history = FALSE,
valid_values = NULL,
...
)Arguments
- x
A climasus_df object (required for get/set operations, optional for
valid_values)- field
Character. Specific metadata field to retrieve. One of: "system", "stage", "type", "spatial", "temporal", "created", "modified", "history", "user".
- add_history
Character. Add entry to processing history with automatic timestamp.
- print_history
Logical. If TRUE, prints processing history to console.
- valid_values
Character. Get valid values for a field. One of: "system", "stage", "type". Does not require
x.- ...
Named arguments to update metadata (e.g.,
system = "SIH",stage = "clean").
Value
Depends on the operation:
Get all metadata: Returns list with all metadata (no additional args)
Get specific field: Returns value of requested field
Update metadata: Returns updated climasus_df object
Add history: Returns updated climasus_df object with new history entry
Print history: Returns NULL invisibly after printing
Valid values: Returns character vector of valid values
Details
The function behavior depends on which arguments are provided:
Get Operations:
climasus_meta(x)- Get all metadata as a listclimasus_meta(x, "system")- Get specific field value
Set Operations:
climasus_meta(x, system = "SIH", stage = "clean")- Update metadataclimasus_meta(x, add_history = "Filtered data")- Add history entry
Utility Operations:
climasus_meta(x, print_history = TRUE)- Print processing historyclimasus_meta(valid_values = "system")- Get valid system values
Examples
if (FALSE) { # \dontrun{
# Create climasus_df (done internally by pipeline functions)
df <- data.frame(x = 1:10, y = letters[1:10])
df <- new_climasus_df(df, list(system = "SIH", stage = "import"))
# Get all metadata
meta <- climasus_meta(df)
str(meta)
# Get specific field
system <- climasus_meta(df, "system") # "SIH"
stage <- climasus_meta(df, "stage") # "import"
# Update metadata
df <- climasus_meta(df, stage = "clean", type = "clean")
# Add to processing history
df <- climasus_meta(df, add_history = "Removed missing values")
df <- climasus_meta(df, add_history = "Standardized column names")
# Print history
climasus_meta(df, print_history = TRUE)
# Get valid values (no x needed)
systems <- climasus_meta(valid_values = "system")
stages <- climasus_meta(valid_values = "stage")
} # }