QQ chart programming

I have a math test sample for male and female students. I want to draw a QQ graph for each gender to find out if each of them is normally distributed. I know how to draw a QQ graph for a general sample, but how can I draw them separately?

+4
source share
1 answer

Here is a simple solution using base graphics:

 scores <- rnorm(200, mean=12, sd=2) gender <- gl(2, 50, labels=c("M","F")) opar <- par(mfrow=c(1,2)) for (g in levels(gender)) qqnorm(scores[gender==g], main=paste("Gender =", g)) par(opar) 

A more elegant lattice solution, and then:

 qqmath(~ scores | gender, data=data.frame(scores, gender), type=c("p", "g")) 

See the online help for qqmath for a more in-depth discussion and an example of customization.

+5
source

Source: https://habr.com/ru/post/1380896/


All Articles