In R I am trying to plot some data to which I will fit a glm. I want to make it obvious which data points have which factors associated to them. The data has response variable y=survivors vs x=year of graduation. I have 2 further explanatory variables, age and faculty. I'm currently using the code
plot(year,survive,pch=as.character(faculty))
to plot year vs survivors, and this changes each data point in the graph to be a letter, is there a way i can either a) specify the symbol for each faculty (there are 4) so they are different (circles/triangles etc) b) plot each faculty individually, and get 4 plot with one faculty on each?
a) You can use the library ggplot2:
library(ggplot2)
ggplot(yourdataset) + geom_point(aes(y=year, x=survive, colour=faculty, shape=faculty))
(adding also different colors is usually better)
b) You can create 4 graphs by:
plot(year ~ survive, data=yourdataset[yourdataset$faculty == "yourname",])
everytime changing "yourname" to the desired value.