save_eim {fastei}R Documentation

Save an eim object to a file

Description

This function saves an eim object to a specified file format. Supported formats are RDS, JSON, and CSV. The function dynamically extracts and saves all available attributes when exporting to JSON. If the prob field exists, it is saved when using CSV; otherwise, it yields an error.

Usage

save_eim(object, filename, ...)

Arguments

object

An eim object.

filename

A character string specifying the file path, including the desired file extension (.rds, .json, or .csv).

...

Additional arguments (currently unused but included for compatibility).

Details

Value

The function does not return anything explicitly but saves the object to the specified file.

See Also

The eim object implementation.

Examples


model <- eim(X = matrix(1:9, 3, 3), W = matrix(1:9, 3, 3))

model <- run_em(model)

td <- tempdir()
out_rds <- file.path(td, "model_results.rds")
out_json <- file.path(td, "model_results.json")
out_csv <- file.path(td, "model_results.csv")

# Save as RDS
save_eim(model, filename = out_rds)

# Save as JSON
save_eim(model, filename = out_json)

# Save as CSV
save_eim(model, filename = out_csv)

# Remove the files
files <- c(out_rds, out_json, out_csv)
file.remove(files)



[Package fastei version 0.0.0.7 Index]