| split_by_key | R Documentation |
This function scans a source directory for JSON files, loads them, and splits each file into multiple smaller JSON files based on the unique values of a specified key. Each unique value results in a separate file.
split_by_key(input_dir, output_dir, split_key, data_path = NULL)
input_dir |
Character. Path to the directory containing source JSON files. |
output_dir |
Character. Path to the directory where split files will be saved. |
split_key |
Character. The name of the key/field used to isolate unique values (e.g., "Name of country" or "Sample matrix"). |
data_path |
Character. If the JSON has a nested structure (like Norman API), provide the name of the element containing the list of records (e.g., "Data"). Defaults to NULL (assumes the JSON is a top-level list). |
The function creates the output directory if it does not exist. Filenames are generated using the pattern: original_name.json.
Logical. Returns TRUE if the operation completes successfully.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.