R/get_xml_files_param_df.R
get_xml_files_param_df.RdExtracting a data.frame of parameters values for an xml file or a set of (whatever the xml file kind)
get_xml_files_param_df(file_path, param_names = NULL, wide_shape = FALSE)A single long data.frame with name, type, param, id and value columns, value is of type character. or a wide a data.frame with name, type, and all other columns correspond to parameter names, with indices as suffix for multiple values (as in _tec.xml files for water supply, N supply, ...)
An extract of returned data.frames with the 2 formats from an usms.xml file as input
Default data.frame long format
| name | type | param | id | value |
| SugarCane | usms | datedebut | NA | 286 |
| SugarCane | usms | datefin | NA | 650 |
| SugarCane | usms | finit | NA | canne_ini.xml |
| SugarCane | usms | nomsol | NA | solcanne |
| SugarCane | usms | fstation | NA | climcanj_sta.xml |
| ... | ... | ... | ... | ... |
| ... | ... | ... | ... | ... |
| param_gen.xml | fichierpar | Qmulchdec | 17 | 0 |
| param_gen.xml | fichierpar | Qmulchdec | 18 | 0 |
| param_gen.xml | fichierpar | Qmulchdec | 19 | 0 |
| param_gen.xml | fichierpar | Qmulchdec | 20 | 0 |
| param_gen.xml | fichierpar | Qmulchdec | 21 | 0 |
name: a file name or an usm or soil name type: type of file param: param name id: NA for scalar, integer id for vectors parameters value: parameter value
wide data.frame format
| name | type | datedebut | datefin | finit | nomsol |
| SugarCane | usms | 286 | 650 | canne_ini.xml | solcanne |
| potato | usms | 91 | 250 | patate_ini.xml | solpatate |
| banana | usms | 30 | 300 | banane_ini.xml | solbanane |
| sorghum | usms | 112 | 360 | sorgho_ini.xml | solsorgho |
| barley | usms | 88 | 196 | orge_ini.xml | solorge |
name: a file name or an usm or soil name type: type of file all other columns names correspond to parameter names, with indices as suffix for multiple values (as in _tec.xml files)
if (FALSE) { # \dontrun{
dir_path <- get_examples_path("xml")
get_xml_files_param_df(
file_path = file.path(dir_path, "sols.xml")
)
files_list <- file.path(dir_path, c("sols.xml", "usms.xml", "param_gen.xml"))
# long format (default)
get_xml_files_param_df(file_path = files_list)
# wide format
get_xml_files_param_df(file_path = files_list, wide_shape = TRUE)
} # }