6.1 Technical aspects

The workflow to create the report follow three steps:

  1. run the analysis and create a list with all results
  2. create a .Rmd template that will be shared by all locations
  3. run rmarkdown::render() in order to generate report for each location

6.1.1 Run the analysis Format data

data_model_GxE = format_data_PPBstats(data_model_GxE, type = "data_agro")
## data has been formated for PPBstats functions. Descriptive plots for each location

vec_locations = levels(data_model_GxE$location)
list_hist_locations = lapply(
  vec_locations, function(x){
    p = plot(
      data_model_GxE, plot_type = "histogramm",
      vec_variables = c("y1")
names(list_hist_locations) = vec_locations

Note that it is important that each element of the list refers to data of a given location in order to catch the right information in the next step when generating the report. GGE model for all locations

The function workflow_gxe() is coming from section 3.6.3.

vec_variables = c("y1")
res_gge = lapply(vec_variables, workflow_gxe, "GGE")
## GGE model done for y1
names(res_gge) = vec_variables Create a list with all results

res = list("hist_locations" = list_hist_locations, 
           "res_gge" = res_gge

6.1.2 Create a .Rmd template

Your template call two objects:

  • params which is list with parameter of the report
  • res which is a list with all results coming from the analysis

Below is an example of a minimal template:

title: "`r params$title`"
date: "`r format(Sys.time(), '%d %B %Y')`"
author: Flower Seed
    toc: TRUE
    toc_float: TRUE

```{r global_options,include=FALSE}
knitr::opts_chunk$set(echo=FALSE, warning=FALSE, message=FALSE)

# Introduction
Here is a beautiful report with all results of the year !

# Description of data on the location

p = res$hist_locations[[location]]
if(is.null(p)){print("No data for y1")}else {p}

# GGE analysis for the three locations

The germplasm effects are the following:


The which won where plot is the following:


6.1.3 Generate a report for each location

To generate the report, you need the R package rmarkdown installed. In the following example, the output is .html. You can choose .pdf or .docx. See ?rmarkdown::render for more information.


vec_locations = names(res$hist_locations)
for (location in vec_locations){ # For each location, render a report
  params = list("title" = paste("Agronomic analyses for", location))
                    output_file =  paste("report_", location, "_", ".html", sep = ""), 
                    output_dir = "."

The report generated can be visualized for loc-1, loc-2 and loc-3.

More examples of worklows with script, template and outputs can be found here.