Structures representing a directory of data files
gadget_directory(dir, mainfile = "main") gadget_dir_write(gd, obj) gadget_dir_read(gd, file_name, missing_okay = TRUE, file_type = c())
Name of directory, will be created if it doesn't exist.
Name of the GADGET mainfile to use.
File to read out of the directory and turn into a
If true, return an empty file instead of complaining that the given file does not exist.
A character vector that alters how the file is parsed. Currently either NULL or "bare_component", which implies we write "something" instead of "[something]".
These functions handle reading and writing of files to a directory containing GADGET model files.
First a gadget_directory object needs to be created with
this ensures the directory exists and stores the name of the mainfile to use.
Any portion of a gadget model can then be written out with
You do not need to tell it which files in the model to update, since this is worked
out based on what you are writing out.
gadget_directory returns a list of class 'gadget_directory',
containing the location of the mainfile that the gadget configuration will use.
gadget_dir_write returns NULL
gadget_dir_read returns a gadget_file object from
# Create a gadget directory gd <- gadget_directory(tempfile()) # Read in the likelihood file likelihood <- gadget_dir_read(gd, 'likelihood') # Write out an area file to "(tempfile)/areas", replacing any existing file gadget_dir_write(gd, gadget_file("areas", components = list(list(north = 1:3, south = 4:7)))) # Replace a likelihood component if one already exists with # the same name/type or append it to the bottom gadget_dir_write(gd, gadget_likelihood_component("understocking", name = "frank"))