Scatterplot Matrices
When we have two or more variables and we want to correlate between one variable and others so we use a R scatterplot matrix.
pairs() function is used to createR matrices of scatterplots.
Syntax: pairs(formula, data)
Parameters:
- formula: This parameter represents the series of variables used in pairs.
- data: This parameter represents the data set from which the variables will be taken.
Example:
R
# Plot the matrices between # 4 variables giving 12 plots. # One variable with 3 others # and total 4 variables. pairs (~wt + mpg + disp + cyl, data = mtcars, main = "Scatterplot Matrix" ) |
Output:
Scatter plots in R Language
A scatter plot is a set of dotted points representing individual data pieces on the horizontal and vertical axis. In a graph in which the values of two variables are plotted along the X-axis and Y-axis, the pattern of the resulting points reveals a correlation between them.