export_list {mintyr} | R Documentation |
Export List with Advanced Directory Management
Description
The export_list
function exports a list of data.frame
, data.table
, or compatible data structures
with sophisticated directory handling, flexible naming, and multiple file format support.
Usage
export_list(split_dt, export_path = tempdir(), file_type = "txt")
Arguments
split_dt |
A |
export_path |
Base directory path for file export. Defaults to a temporary directory
created by |
file_type |
File export format, either |
Details
Comprehensive List Export Features:
Advanced nested directory structure support based on list element names
Intelligent handling of unnamed list elements
Automatic conversion to
data.table
for consistent exportHierarchical directory creation with nested path names
Multi-format file export with intelligent separator selection
Robust error handling and input validation
File Export Capabilities:
Supports
"txt"
(tab-separated) and"csv"
formatsIntelligent file naming based on list element names
Handles complex nested directory structures
Efficient file writing using
data.table::fwrite()
Value
An integer
representing the total number of files exported successfully.
Note
Key Capabilities:
Flexible list naming and directory management
Comprehensive support for
data.frame
anddata.table
inputsIntelligent default naming for unnamed elements
High-performance file writing mechanism
Examples
# Example: Export split data to files
# Step 1: Create split data structure
dt_split <- w2l_split(
data = iris, # Input iris dataset
cols2l = 1:2, # Columns to be split
by = "Species" # Grouping variable
)
# Step 2: Export split data to files
export_list(
split_dt = dt_split # Input list of data.tables
)
# Returns the number of files created
# Files are saved in tempdir() with .txt extension
# Check exported files
list.files(
path = tempdir(), # Default export directory
pattern = "txt", # File type pattern to search
recursive = TRUE # Search in subdirectories
)
# Clean up exported files
files <- list.files(
path = tempdir(), # Default export directory
pattern = "txt", # File type pattern to search
recursive = TRUE, # Search in subdirectories
full.names = TRUE # Return full file paths
)
file.remove(files) # Remove all exported files