Is there an easy way to create a graph pairsthat compares only one variable with many others? In other words, can I build only one row or column of the standard scattering matrix pairswithout using a loop?
pairs
Fuse your data, then use ggplot with a 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 will dfget around it with the base build option (using from @ zx8754):
df
layout(matrix(seq(ncol(df)-1),nrow=1)) Map(function(x,y) plot(df[c(x,y)]), names(df[1]), names(df[-1]))
Although possible, it is still a loop using Map.
Map
, lattice ( @zx8754 "df_melt" ):
lattice
library(lattice) xyplot(value ~ x | variable, data = df_melt, layout = c(3,1), between = list(x=1))