QQ plot: More than two data
plot, r
Solution
I suppose you're looking for a scatterplot of sorted values since all variables are stored in the same data frame.
An example dataset:
set.seed(10)
dat <- data.frame(A = rnorm(20), B = rnorm(20), C = rnorm(20))
This is a way to create the plot with basic R functions:
# create a QQ-plot of B as a function of A
qqplot(dat$A, dat$B, xlim = range(dat), ylim = range(dat),
xlab = "A", ylab = "B/C")
# create a diagonal line
abline(a = 0, b = 1)
# add the points of C
points(sort(dat$A), sort(dat$C), col = "red")
# create a legend
legend("bottomright", legend = c("B", "C"), pch = 1, col = c("black", "red"))
Problem
I wanted to graph a QQ plot similar to this picture: I managed to get a QQ plot using two samples, but I do not know how to add a third one to the plot. Here is my result: Here is the code I used: ``` qqplot(table$Bedouin, table$Tunisia, xlim = c(-0.25,0.25), ylim = c(-025,0.25)) ``` In my table data frame I have other populations I would like to add. But I can't. Thank you in advance.