Scatterplot matrices are a great way to roughly determine if you have a linear correlation between multiple variables.

For a set of data variables (dimensions) X_{1}, X_{2}, … , X_{k}, the scatter plot matrix shows all the pairwise scatter plots of the variables on a single view with multiple scatterplots in a matrix format.

This is a custom scatterplot matrix made using the car package. See other examples of scatter plot matrix in graph #97 and graph #98

1 2 3 4 5 6 7 8 9 10 11 12 |
# Packages library(car) library(RColorBrewer) # Let's use the car dataset proposed by R data=mtcars # Make the plot my_colors <- brewer.pal(nlevels(as.factor(data$cyl)), "Set2") scatterplotMatrix(~mpg+disp+drat|cyl, data=data , reg.line="" , smoother="", col=my_colors , smoother.args=list(col="grey") , cex=1.5 , pch=c(15,16,17) , main="Scatter plot with Three Cylinder Options") |

Not what you are looking for ? Make a new search !

`[mediatagger]`

## Leave a Reply

2 Comments on "#99 Scatterplot matrix – car package"

The example does not work:

my_colors <- brewer.pal(nlevels(as.factor(data$cyl)), "Set2")

Error in data$cyl : object of type 'closure' is not subsettable

Hi,

I just retried the code it snippet and it works fine for me! Are you sure you copied and pasted the whole code? Do you have all the requested packages? Which version of R do you have?