knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(qp4ewc)

Aim

In this vignette, you will get more information about the construction of the main-function post_process_output. This take is to extract from the result file of ECOWEIGHT specific for beef cattle economic weights and population means for a specific scenario.

The input-files are produced under the vignette 1_Manual_Preprocess_EWBC, the ECOWEIGHT for beef cattle (EWBC) has been executed. This part need to be done separately and is not part of the package qp4ewc. As soon as we have the result file of EWBC, we can run the post-processing part to extract economic weights and population means.

To show how post_process_output is build, we made some test-file from ECOWEIGHT (EWBC).

Post-processing part

The major steps of post_process_output are

1) function extract_ewbc() : the task is to extract economic weights from the output-parameter-file of ECOWEIGHT beef on beef

2) function extract_popmean_ewbc() : the task is to extract or calculate population mean from the output-parameter-file of ECOWEIGHT beef on beef

3) function combine_popmean() : the task is to combine information extracted, this means economic weight and population means for specific traits of beef on beef

4) function save_csv_table_piechart_ewdc() : the task is to save the scenario result as csv-file as well as to produce a pdf with a table and piecharts per scenario for beef on beef.

Parameters

# Sire breed can be: AN,AU,CH,LM,OB,SI corresponding to Angus,Aubrac, Charolais, Limousin, Original-Braunvieh, Simmental
s_sirebreed <- "LM"
# Dam breed can be for beef-on-beef: AN,AU,CH,LM,OB,SI corresponding to Angus,Aubrac, Charolais, Limousin, Original-Braunvieh, Simmental 
s_dambreed <- "LM"
# Production system according to ECOWEIGHT for beef-on-beef: 1,2,3 corresponding to purebreeding, crossbreeding, terminal crossing
s_prodsystem <- "1"
# Marketing channel can be: Natura-Beef, SwissPrimBeef
s_marketingchannel <- "Natura-Beef"
# Path to define from the working directory
s_path_directory2create <- file.path(here::here(),"inst","extdata","ewbc","test","Ecoweight_output")
# Path to input from the literature research. Based on this example an other file can be created with different input-value and input-source.
# Flag to set to TRUE, if a log-file is whished
b_log <- TRUE
#Path to file
s_path_2outputfile <- system.file("extdata","ewbc","Ecoweight_output", package = "qp4ewc")
# Name of output file of ECOWEIGHT
s_outputfilenameECOWEIGHT <- "test"
# Path to output statements from the results file of ewbc
s_output_statement <-  system.file("extdata","ewbc","output_statement.txt", package = "qp4ewc")
# Path to search patterns needed to find correct results 
s_output_search_pattern <- system.file("extdata","ewbc","output_searchpattern.txt", package = "qp4ewc")
# Path to genetic standard deviation values 
s_input_genetic_SD <- system.file("extdata","ewbc","input_geneticSD.txt", package = "qp4ewc")
# Scenario
s_scenario <- paste0(s_sirebreed,"_",s_dambreed, "_",s_prodsystem,"_",s_marketingchannel,"_test",collapse = "")
# Path to save table of result 
s_path_extracted_results <- file.path(here::here(),"inst", "extdata", "ewbc", "results")

At the beginning of the function depending of the setting for pb_log and plogger, a log-file will be created.

Run post_process_output() in RStudio

post_process_output(ps_path_2outputfile = s_path_2outputfile,
                    ps_outputfilenameECOWEIGHT = s_outputfilenameECOWEIGHT,
                    ps_output_statement = s_output_statement,
                    ps_output_search_pattern = s_output_search_pattern,
                    ps_sirebreed = s_sirebreed,
                    ps_dambreed = s_dambreed,
                    ps_prodsystem = s_prodsystem,
                    ps_marketchannel = s_marketingchannel,
                    ps_path_directory2create = s_path_directory2create,
                    ps_scenario = s_scenario,
                    ps_path_tbl_save = s_path_extracted_results,
                    ps_input_genetic_SD = s_input_genetic_SD,
                    pb_log = b_log)

Now you can have a look under s_path_extracted_results to the result-files (.csv and .pdf).

Because numerous scenari can be calculated, in the vignette 3_Manual_Overview_scenari_EWBC, you can find an extra function how to sort the scenari by s_sirebreed or dambreed or marketing channel to facilitate the interpretation of the results.



sknqualitasag/qp4ewc documentation built on Sept. 27, 2022, 3:31 p.m.