R/cropr_formatting.R
format_cropr.RdFormat simulations (and observations if any) for plotting. This function can be used as a template to include other models in CroPlotR.
A simulation data.frame
An observation data.frame
A data.frame with observation standard deviations
The type of plot required, either "dynamic" or "scatter"
Which data to plot when type= "dynamic"? See details.
Which data to plot when type= "scatter"? See details.
Boolean (default = FALSE). If TRUE, plot all
situations on the same graph.
If TRUE, sim and obs are respectively an element of the first
element and the
second element of the output of cat_situations.
A list of lists containing the situations to be represented
as a contiguous sequence when type = "dynamic" (dates should be contiguous)
when type = "dynamic" (implies that the situations are correctly ordered).
Variable selected on x-axis when type is scatter and select_scat is res. It is possible to select between observation and simulation of the reference variable.
Logical value for displaying information while running.
A pre-formatted data.frame or NULL if the formatting is not
possible (e.g. type="scatter" but no common variables in obs and sim).
The select_dyn argument can be:
"sim" (the default): all variables with simulations outputs, and observations when there are some
"common": variables with simulations outputs and observations in common
(used when type= "scatter" )
"obs": all variables with observations, and simulations outputs when there are some
"all": all variables with any observations or simulations outputs
The select_scat argument can be:
"sim" (the default): plots observations in X and simulations in Y.
"res": plots observations in X and residuals(observations-simulations)in Y.
if (FALSE) { # \dontrun{
# remotes::install_github("SticsRPacks/SticsRPacks")
workspace <- system.file(file.path("extdata", "stics_example_1"),
package = "CroPlotR"
)
situation <- SticsRFiles::get_usms_list(
file =
file.path(workspace, "usms.xml")
)[1]
sim <- SticsRFiles::get_sim(workspace = workspace, usm = situation)
obs <- SticsRFiles::get_obs(workspace = workspace, usm = situation)
formated_df <- format_cropr(
sim$`IC_Wheat_Pea_2005-2006_N0`,
obs$`IC_Wheat_Pea_2005-2006_N0`
)
options(max.print = 100)
formated_df
} # }