Is there a parsimonious way to create a pairs
plot that only compares one variable to the many others? In other words, can I plot just one row or column of the standard pairs
scatter plot matrix without using a loop?
Interpreting scatter plotsCheck for negative relationships between the two variables in the plot. If you see low values for the first variable and high values of the second variable, there is a negative correlation. In this case, a line drawn through the data points will slope downwards i.e. a negative slope.
The kind of correlation can be interpreted through the patterns revealed on a Scatterplot. These are: positive (values increase together), negative (one value decreases as the other increases) or null (no correlation). The shape of the correlation can be described as: linear, exponential and U-shaped.
You can have more than one dependent variable. Your data set might include more than one dependent variable, and you can still track this on a scatter plot. The only thing you'll want to change is the color of each dependent variable so that you can measure them against each other on the scatter plot.
Melt your data then use ggplot with facet.
library("ggplot2")
library("reshape2")
#dummy data
df <- data.frame(x=1:10,
a=runif(10),
b=runif(10),
c=runif(10))
#melt your data
df_melt <- melt(df,"x")
#scatterplot per group
ggplot(df_melt,aes(x,value)) +
geom_point() +
facet_grid(.~variable)
I'll round it out with a base plotting option (using df
from @zx8754):
layout(matrix(seq(ncol(df)-1),nrow=1))
Map(function(x,y) plot(df[c(x,y)]), names(df[1]), names(df[-1]))
Although arguably this is still a loop using Map
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With