Created
January 8, 2013 16:18
-
-
Save meren/4485081 to your computer and use it in GitHub Desktop.
a substitute for qqplot and qqline.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################################################################################### | |
# Q-Q plot in ggplot2 | |
# taken from http://stackoverflow.com/questions/4357031/qqnorm-and-qqline-in-ggplot2 | |
##################################################################################### | |
require(ggplot2) | |
vec <- Hg$AMT # whateer | |
y <- quantile(vec[!is.na(vec)], c(0.25, 0.75)) | |
x <- qnorm(c(0.25, 0.75)) | |
slope <- diff(y)/diff(x) | |
int <- y[1L] - slope * x[1L] | |
d <- data.frame(resids = vec) | |
ggplot(d, aes(sample = resids)) + stat_qq() + geom_abline(slope = slope, intercept = int) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment