Overwrites the body of a named section in a .ferx file with new lines, leaving all other sections untouched. Use this to modify a model programmatically without opening an editor.

ferx_model_set_section(path, section, lines)

Arguments

path

Path to a .ferx model file.

section

Name of the section to replace, without brackets (e.g. "fit_options").

lines

Character vector of replacement lines. These become the new body of the section (do not include the [section] header line).

Value

path, invisibly.

Examples

if (FALSE) { # \dontrun{
# Switch estimation method without opening an editor
ferx_model_set_section("my_model.ferx", "fit_options", c(
  "  method     = focei",
  "  maxiter    = 500",
  "  covariance = false"
))

# Read-modify-write a section
lines <- ferx_model_section("my_model.ferx", "parameters")
lines <- sub("TVCL\\(.*\\)", "TVCL(0.5, 0.001, 10.0)", lines)
ferx_model_set_section("my_model.ferx", "parameters", lines)
} # }