I've made a plot of variables lsiete and lcinco with the following code:
qplot(lsiete, lcinco, data=enc, color=LENGTHE)
However, I also want to give colour to the scatter plot by the following factor variables to visualize it all at the same time:
> names(enc[,ind])
[1] "SEX" "RACE" "MSTATUS" "EDUC" "POSITION" "SATSCHED" "TYPESCH" "FLEX" "URBRUR" "HOURS"
[11] "SCHOOL" "ANJOB" "TYPERES" "LENGTHE" "HOWLONG" "REASONQ" "REASONW" "WHY"
So, I want a panel with all the possible scatter plots with the mentioned condition.
How Can I write the code to do that?
EDIT: To be more clear, lsiete
and lcinco
doesnt change, instead the variables in color change
EDIT 2: To give a reproducible example. I create the following data frame with random data:
sn <- data.frame(a=rnorm(100),b=rnorm(100), cat1=sample(c('male', 'female'), 100, replace=TRUE),cat2=sample(c('U', 'AL'), 100, replace=TRUE),cat3=sample(c('AR', 'ML'), 100, replace=TRUE),cat4=sample(c('LM', 'KR'), 100, replace=TRUE))
I can create a qplot with a and b, and give colour according to cat2:
qplot(a,b,data=sn,color=cat2)
But, I want to keep a and b always, and give colour according the rest of categorical variables to have a panel of all possible scatterplots.