summaryHTML.R

#' @title Summary HTML docuement .
#' @name summaryHTMl
#' @description Calls the summaryHTML rmd file information from all insitu, exsitu, and EOO AOO summaries and displays
#' The content. The code also produces insitu and exsitu gap maps which can be writen out to disk.
#'
#'
#'  \deqn{FCSex = mean(SRSex,GRSex,ERSex)}
#'
#' @param species A name species compiled using '_'  to call occurrences files from Workspace/parameter/occurrences folder
#' @param Workspace A forder where the pipeline will be executed
#' @param  run_version The version of the analysis used (e.g 'v1')
#'
#' @return It returns a data frame file saved at gap_analysis folder with five fields:
#'
#' \tabular{lcc}{
#'  ID \tab Species name \cr
#'  SRS \tab Ex-situ sample representativeness score \cr
#'  GRS \tab Ex-situ germplasm representativeness score \cr
#'  ERS \tab Ex-situ environmental representativeness score  \cr
#'  FCS \tab Ex-situ final conservation score  \cr
#' }
#'
#' @examples fcs_exsitu('Cucurbita_digitata',Workspace,'v1')
#'
#' Workspace  <-  'E:/CIAT/workspace/Workspace_test/workspace'
#' run_version  <- 'v1'
#' species_list <- c('Cucurbita_cordata',
#'  'Cucurbita_digitata',
#'  'Cucurbita_foetidissima',
#'  'Cucurbita_palmata')
#'
#'  run_version <-'v1'
#
#' lapply(1:length(species_list),function(i){
#'    species <- species_list[[i]]
#'    x <- fcs_exsitu(species,Workspace,run_version)
#'    print(paste0(species,' DONE!'))
#' })
#'
#'@references
#'
#'Ramírez-Villegas, J., Khoury, C., Jarvis, A., Debouck, D. G., & Guarino, L. (2010).
#'A Gap Analysis Methodology for Collecting Crop Genepools: A Case Study with Phaseolus Beans.
#'PLOS ONE, 5(10), e13497. Retrieved from https://doi.org/10.1371/journal.pone.0013497
#'
#' Khoury, C. K., Amariles, D., Soto, J. S., Diaz, M. V., Sotelo, S., Sosa, C. C., … Jarvis, A. (2019).
#' Comprehensiveness of conservation of useful wild plants: An operational indicator for biodiversity
#' and sustainable development targets. Ecological Indicators. https://doi.org/10.1016/j.ecolind.2018.11.016
#'
#' @export

##########################################   Start Functions    ###############################################
# This function calculates the FCSex. It loads srs.csv, grs.csv, ers.csv and
# calculates FCS. It saves output in summary.csv
# @param (string) species: species ID
# @return (data.frame): This function returns a data frame with ID, SRS, GRS, ERS, FCS

summaryHTML <- function(species_list,occurrenceData, raster_List, bufferDistance,
                        countsSummary, insituSummary, exsituSummary,
                        fcsSummary, eooAooSummary, outputFolder,
                        writeRasters){

rmarkdown::render(input = system.file("summaryHTML.Rmd",package = "gapAnalysisR"),
      output_dir = outputFolder,
      output_file  = "SummaryReport.html"
       )

}
dcarver1/gapAnalysisR documentation built on Feb. 29, 2020, 12:13 p.m.