replace_value: Helper function: replace value

View source: R/abimo_functions_am.R

replace_valueR Documentation

Helper function: replace value

Description

searches string for parameter=<pattern_value> and replaces with parameter=<new_value> for all found entries

Usage

replace_value(
  string,
  new_value,
  parameter = "etp",
  pattern_value = "\"[0-9]+?\\.?[0-9]+?\""
)

Arguments

string

string with ABIMO config

new_value

new parameter value

parameter

parameter name to search for (default: "etp")

pattern_value

pattern of value field (default: '\"[0-9]+?\.?[0-9]+?\"')

Value

returns string with modified parameter = value

Examples

### Simple string
string <- '<item bezirke="15,16,18,19,20" etp="807" etps="600" />'
replace_value(string, new_value = 100, parameter = "etp")
replace_value(string, new_value = 100, parameter = "etps")
### Default ABIMO config
config <- readLines(kwb.abimo::default_config())
replace_value(config, new_value = 100, parameter = "etp")

KWB-R/kwb.abimo documentation built on Feb. 14, 2024, 9:42 a.m.