export_data {HARplus}R Documentation

Export Data to Various Formats (CSV/STATA/TEXT/RDS/XLSX)

Description

Exports structured SL4 or HAR data to multiple file formats, including CSV, Stata, TXT, RDS, and XLSX. Supports nested lists, automatic subfolder creation, and multi-sheet Excel exports.

Usage

export_data(
  data,
  output_path,
  format = "csv",
  prefix = "",
  create_subfolder = FALSE,
  multi_sheet_xlsx = FALSE,
  xlsx_filename = NULL,
  report_output = FALSE
)

Arguments

data

A list or data frame. The SL4 or HAR data to export.

output_path

Character. The base output directory or file path.

format

Character. The export format ("csv", "stata", "txt", "rds", "xlsx"). Default is "csv".

prefix

Character. An optional prefix added to exported file names. Default is "" (empty).

create_subfolder

Logical. If TRUE, creates a subfolder for each format. Default is FALSE.

multi_sheet_xlsx

Logical. If TRUE, exports lists as multi-sheet XLSX files.

xlsx_filename

An optional filename for the XLSX file (used when multi_sheet_xlsx = TRUE).

report_output

Logical. If TRUE, generates an export report.

Details

Value

A list containing the file paths of the exported data.

Author(s)

Pattawee Puangchit

See Also

pivot_data, get_data_by_var, get_data_by_dims

Examples


# Import sample data:
sl4_data <- load_sl4x(system.file("extdata", "TAR10.sl4", package = "HARplus"))

# Extract data
data_multiple <- get_data_by_var(c("qo", "pca"), sl4_data)

# Export
export_data(data_multiple, file.path(tempdir(), "output_directory"), 
           format = c("csv", "xlsx", "stata", "txt", "rds"),
           create_subfolder = TRUE,
           multi_sheet_xlsx = TRUE)



[Package HARplus version 1.0.1 Index]