R/plot_precissionp.R

Defines functions plot_precissionp

Documented in plot_precissionp

#' Precission plot
#'
#' Precission plot
#'
#' @param x Data
#' @param filename optional, file name to write the plot with png format
#' @param main optional, string with plot title
#'
#' @return distribution plot
#'
#' @export
plot_precissionp <- function(x, filename, main= NULL, ...)
{

   if (is.null(main))
      main = "Precision Plot -  1/median(SE) vs sqrt(n)"

   p <- ggplot2::ggplot( data = x, mapping = ggplot2::aes( x = round(as.numeric(sqrt_N),2), y = round(as.numeric(invSE),2) ) ) +
      ggplot2::theme_bw() +
      ggplot2::geom_point( size = 3, ggplot2::aes( colour = cohort ) ) +
      #geom_line( aes( group = cohort , colour = cohort ) ) +
      ggplot2::ggtitle( main ) +
      ggplot2::theme( legend.position = "bottom",
                      legend.text = ggplot2::element_text(size=6),
                      legend.title = ggplot2::element_blank()) +
      ggplot2::labs( x = "sqrt(n)",
                     y = "inv SE") +
      ggplot2::scale_shape_manual( values = 0:7 )

   if(!is.null(filename)){
      png(filename, type = "cairo")
         print(p)
      dev.off()
      #..# ggplot2::ggsave(filename,p)
   }

   return(p)


}
isglobal-brge/EASIER documentation built on Feb. 12, 2024, 6:30 p.m.