This tutorial will help you learn about the normal probability plot in the R programming language. As you know, it is used a lot in statistics. So, if you are interested in this topic, please read it below.
What is the normal probability plot in R?
First, we will find out the normal probability in R.
Here, you can understand that the normal probability plot is a graph that depicts the data and is used to determine whether or not a particular data set is normally distributed. It compares data collection to the normal distribution. If data collection is regularly distributed, it will have a straight-line shape.
How to create the normal probability plot in R?
If you want to create a normal probability plot in R, we will use ggplot2 and qqplotr packages. So, if you don’t know to install these packages, you can run the code below:
# Install packages install("ggplot2") install("qqplotr")
Or you can install this packages quickly as follows:
# Install packages install.packages("ggplot2", "qqplotr")
Then, we will load these packages:
# Load packages library(ggplot2) library(qqplotr)
If you want to know more about this function, you can click here.
When successfully installed, you will create a dataset for normal distribution. Then, you can plot the normal probability graph. We will use the stat_qq_point()
, and stat_qq_line()
functions to plot the normal probability. Check out the code example below:
# Load packages library(ggplot2) library(qqplotr) # Random data randomValues <- rnorm(200, mean = 50, sd = 30) # Plot gp <- ggplot(mapping = aes(sample = randomValues)) + stat_qq_point(size = 2) gp
Output

Another example, if you want to plot a red line for further comparison, you can use stat_qq_line()
functions as the following:
# Load packages library(ggplot2) library(qqplotr) # Random data randomValues <- rnorm(200, mean = 50, sd = 30) # Plot gp <- ggplot(mapping = aes(sample = randomValues)) + stat_qq_point(size = 2) + stat_qq_line(color = "red") gp
Output

Summary
So, above is all that this article shares with you to understand how to creat the normal probability plot in R with ggplot2 and qqplotr packages. Please leave a comment if you have any questions. Thanks for reading!
Have a great day, and see you again!
Maybe you are interested:

Hi, guys! My name’s Scott Miller. My current job is a software developer and I have shared a lot of quality articles about Javascript, C, C++, C#, Python, PHP, R, Java programming languages. I’m hoping they can assist you.
Name of the university: HCMUS
Major: IT
Programming Languages: C, C++, Python, R, Java, JavaScript