Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added management if parameters vector values ids for extracting or replacing specific values. #101

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions R/get_param_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#' (optional, default to no selection)
#' @param select_value Vector of values used for select (see examples).
#' Optional, should be provided only if select is provided.
#' @param value_id Vector of ids of the parameters values to be retrieved
#' from the parameter values vector
#' @param value `r lifecycle::badge("deprecated")` `value` is no
#' longer supported, use `select_value` instead.
#' @param ... Pass further arguments to `get_param_value()`
Expand Down Expand Up @@ -48,6 +50,7 @@ get_param_xml <- function(file,
param = NULL,
select = NULL,
select_value = NULL,
value_id = NULL,
xml_file = lifecycle::deprecated(),
param_name = lifecycle::deprecated(),
value = lifecycle::deprecated(),
Expand Down Expand Up @@ -97,6 +100,7 @@ get_param_xml <- function(file,
param_name = param_name,
parent_name = select,
parent_sel_attr = value,
ids = value_id,
...
)
xml_names <- lapply(xml_file, basename) %>% unlist()
Expand Down
25 changes: 23 additions & 2 deletions R/set_param_xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#' (optional, default to no selection)
#' @param select_value Vector of values used for select (see examples).
#' Optional, should be provided only if select is provided.
#' @param value_id Vector of ids of the parameters values to be retrieved
#' from the parameter values vector
#' @param overwrite Logical TRUE for overwriting the output file,
#' FALSE otherwise (default)
#' @param xml_file `r lifecycle::badge("deprecated")` `xml_file` is no
Expand Down Expand Up @@ -71,22 +73,39 @@
#' set_param_xml(sol_path, c("epc", "HCCF"),
#' select = "sol",
#' select_value = c("solcanne", "solbanane"),
#' param_value = list(c(20:24, 10:14), c(50:54, 40:44)), overwrite = TRUE
#' values = list(c(20:24, 10:14), c(50:54, 40:44)),
#' overwrite = TRUE
#' )
#'
#' # Getting changed values
#' # get_param_xml(sol_path, c("epc", "HCCF"),
#' # select = "sol",
#' # select_value = c("solcanne", "solbanane")
#' # )
#'
#' # For specific values of vector parameters
#' set_param_xml(sol_path, "HCCF",
#' select = "sol",
#' select_value = "solcanne",
#' values = c(46.8, 48.5, 50.1),
#' value_id = c(1,3,5),
#' overwrite = TRUE
#' )
#'
#' # Getting changed values
#' # get_param_xml(sol_path, "HCCF",
#' # select = "sol",
#' # select_value = "solcanne",
#' # value_id = c(1,3,5)
#' # )
#'
#' # Crop management file
#'
#' tec_path <- file.path(ex_path, "file_tec.xml")
#'
#' # Modifying irrigations parameters
#' set_param_xml(tec_path, c("julapI_or_sum_upvt", "amount"),
#' param_value = list(200:215, 20:35), overwrite = TRUE
#' values = list(200:215, 20:35), overwrite = TRUE
#' )
#' # Getting changed values
#' # get_param_xml(tec_path, c("julapI_or_sum_upvt", "amount"))
Expand All @@ -99,6 +118,7 @@ set_param_xml <- function(file,
save_as = NULL,
select = NULL,
select_value = NULL,
value_id = NULL,
overwrite = FALSE,
xml_file = lifecycle::deprecated(),
out_path = lifecycle::deprecated(),
Expand Down Expand Up @@ -188,6 +208,7 @@ set_param_xml <- function(file,
param_value = param_value,
parent_name = select,
parent_sel_attr = value,
ids = value_id,
...
)

Expand Down
4 changes: 4 additions & 0 deletions man/get_param_xml.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 23 additions & 2 deletions man/set_param_xml.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading