R/savePlots.R

Defines functions savePlots

Documented in savePlots

#' Function that saves plots
#' 
#' Function that saves plots in multiple formats
#' 
#' @param plotObject plot object generated by each draw plot function
#' @param fileFormat format of the files to be generated (default .png and .pdf)
#' @param plotTypeValue name of type of plot used (name defined by default in each draw plot function)
#' @param widthValue width of the plot (defined by default in each draw plot function)
#' @param heightValue height of the plot (defined by default in each draw plot function)
#' @param measureUnitsValue measure units of the plot (default cm)
#' @param extraInfoValue extra information to be appended to the file name
#' 
#' @export savePlots

## add option for specific sample or recursive, if true, then pltos for all samples
savePlots <- function(plotObject,plotTypeValue,fileFormat = c(".png",".pdf"), widthValue, heightValue, measureUnitsValue = "cm", extraInfoValue){
  # Save plots in different file formats
  for (i in fileFormat) {
    ggsave(plot = plotObject,
           filename = paste0("../Results/", plotTypeValue, "/",format(Sys.time(), "%Y%m%d_%H%M%S"),extraInfoValue,i),
           width = widthValue,
           height = heightValue,
           units = measureUnitsValue,limitsize = FALSE)
  }
}
fpestana-git/visualisR documentation built on May 2, 2022, 11:58 a.m.