R/myFUN_ggplotRegression.R

#' A regression FUnction
#'
#' This function allows to plot a regression with all wanted values
#' @param fit is the before runed lm model which you want to plot now
#' @keywords regression
#' @export
#' @examples
#' myFUN_ggplotRegression()
myFUN_ggplotRegression <- function (fit) {
  
  require(ggplot2)
  
  ggplot(fit$model, aes_string(x = names(fit$model)[2], y = names(fit$model)[1])) + 
    geom_point() +
    stat_smooth(method = "lm", col = "red") +
    labs(title = paste("Entry", ent, "Adj R2 = ",signif(summary(fit)$adj.r.squared, 5),
                       "Intercept =",signif(fit$coef[[1]],5 ),
                       " Slope =",signif(fit$coef[[2]], 5),
                       " P =",signif(summary(fit)$coef[2,4], 5)))
}
agroflavian/GLEIS documentation built on May 18, 2019, 12:24 a.m.