save_BGF: Save a 'BGF' to an external file

View source: R/data_export.R

save_BGFR Documentation

Save a BGF to an external file

Description

Saves a BGF to either a '.csv'- or a '.RDS'-file. It exists one end user function, which internally calls three sub functions, if a '.csv'-file is produced. Otherwise, it acts as a wrapper for saveRDS.

Usage

save_BGF(
  x,
  opath = NULL,
  mkdir = FALSE,
  feedback = FALSE,
  append = FALSE,
  format = "csv",
  ...
)

save_ExpParam(
  x,
  opath = NULL,
  mkdir = FALSE,
  feedback = FALSE,
  append = FALSE,
  ...
)

save_metaData(
  x,
  opath = NULL,
  mkdir = FALSE,
  feedback = FALSE,
  append = FALSE,
  ...
)

save_BioGasData(
  x,
  opath = NULL,
  mkdir = FALSE,
  feedback = FALSE,
  append = FALSE,
  ...
)

Arguments

x

a BGF that should be exported

opath

a path pointing to a location on the system, where the BGF should be saved

mkdir

logic, if TRUE a new directory is created as specified in opath

feedback

logic, if TRUE the function will print a feedback to the R console

append

logic, if TRUE the function assumes that the path specified in opath already includes a file name with an appropriate ending as specified in format. Otherwise a file name will be generated

format

specifies the output generated by the function. Can be either 'csv' or 'RDS'

...

further arguments that can be passed to dir.create.

Details

The main function used to save a BGF as an external data file is save_BGF. The user can choose if the BGF should be saved as an '.RDS'-file or in a human readable '.csv'-file. A human readable '.csv'-file is generated by a consecutive call to the three sub-functions save_ExpParam, save_metaData and save_BioGasData. Each of these functions is designed to write a single layer of the input BGF to an external '.csv'-file.

Value

Either a '.csv' or '.RDS' file created of a BGF

Examples

# create a BGF
myBGF <- BGF(LETTERS[1:5],LETTERS[1],"myBGF",52,2,"manual")


# save it as '.csv' file
save_BGF(myBGF)

# save it as '.RDS' file
save_BGF(myBGF,format="RDS")

# remove files
file.remove("myBGF_BGF_object.csv")
file.remove("myBGF_BGF_object.RDS")

# save only the 'ExpParam' layer
save_ExpParam(myBGF)

# remove file
file.remove("myBGF_ExpParam.csv")

# save only the 'metaData' layer
save_metaData(myBGF)

# remove file
file.remove("myBGF_metaData.csv")

# save only the 'BioGasData' layer
save_BioGasData(myBGF)

# remove file
file.remove("myBGF_BioGasData.csv")


bgfanalyzer documentation built on Sept. 26, 2026, 5:07 p.m.