View source: R/cropr_formatting.R
format_cropr | R Documentation |
Format simulations (and observations if any) for plotting. This function can be used as a template to include other models in CroPlotR.
format_cropr(
sim,
obs = NULL,
obs_sd = NULL,
type = c("dynamic", "scatter"),
select_dyn = c("sim", "common", "obs", "all"),
select_scat = c("sim", "res"),
all_situations = FALSE,
successive = NULL,
reference_var = NULL,
verbose = TRUE
)
sim |
A simulation data.frame |
obs |
An observation data.frame |
obs_sd |
A data.frame with observation standard deviations |
type |
The type of plot required, either "dynamic" or "scatter" |
select_dyn |
Which data to plot when |
select_scat |
Which data to plot when |
all_situations |
Boolean (default = FALSE). If |
successive |
A list of lists containing the situations to be represented
as a contiguous sequence when type = "dynamic" (dates should be contiguous)
when |
reference_var |
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. |
verbose |
Logical value for displaying information while running. |
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.
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).
## Not run:
# 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
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.