Skip to content

Instantly share code, notes, and snippets.

View bravo-diego's full-sized avatar
🎯
Focusing

Diego Godinez Bravo bravo-diego

🎯
Focusing
View GitHub Profile
@rentrop
rentrop / gg_qq.r
Last active December 3, 2023 06:01
This function plots a QQplot as ggplot in R - Parts of the code copied from `car:::qqPlot`
gg_qq <- function(x, distribution = "norm", ..., line.estimate = NULL, conf = 0.95,
labels = names(x)){
q.function <- eval(parse(text = paste0("q", distribution)))
d.function <- eval(parse(text = paste0("d", distribution)))
x <- na.omit(x)
ord <- order(x)
n <- length(x)
P <- ppoints(length(x))
df <- data.frame(ord.x = x[ord], z = q.function(P, ...))