Learn R Programming

PubChemR (version 3.0.0)

pc_export_model_data: Export Model-Ready Data

Description

Writes model-ready data to disk from either a `PubChemModelMatrix` object or a tabular object.

Usage

pc_export_model_data(
  x,
  path,
  format = c("csv", "rds"),
  include_ids = TRUE,
  include_outcome = TRUE
)

Value

Invisibly returns a list with `path`, `format`, and output dimensions.

Arguments

x

Input object. Supported: - `PubChemModelMatrix` - `data.frame`/`tibble`

path

Output path.

format

Export format, one of `"csv"` or `"rds"`.

include_ids

Logical. Include ID columns from `PubChemModelMatrix`.

include_outcome

Logical. Include outcome vector from `PubChemModelMatrix`.

Details

Output format is selected by `format`; `csv` is written with `utils::write.csv()` and `rds` with `saveRDS()`.

Examples

Run this code
out_file <- tempfile(fileext = ".csv")
x <- tibble::tibble(CID = c("1", "2"), x1 = c(0.1, 0.2))
meta <- pc_export_model_data(x, path = out_file, format = "csv")
file.exists(meta$path)

Run the code above in your browser using DataLab