Make scatter plots for multiple subsets of data
Let me introduce my data-set and my preliminary result first for better understanding my question. my dataset looks like:
Place Species Size Conc. A BT 24 0.2 A ST 76 1.4 ... B BT 45 1.2 B ST 21 0.7 ...
I want to make scatterplot of Size against Conc. for each Species at each Place. What I have done uses ggplot2 to make a graph as below:
scatterplot <- ggplot(mydata, aes(x = Size, y = Conc, color = Species)) + geom_point(shape = 1)
Though this graph plots by the species group in different color, it summarizes all data in the dataset and fails to plot for different places.
I think the code below
scatterplot <- ggplot(mydata[mydata$place == "A"], aes(x = Size, y = Conc, color = Species)) + geom_point(shape = 1)
works for plotting just place A and I can do this for different places one by one. However, in my real dataset, the place variable has tons of different places, and I can't type them all out one by one manually. Thus my question actually is how to let R make those plots for different places automatically at one time?
If there are too many places:
ggplot(ddf)+geom_point(aes(Size, Conc., color=Place))+facet_grid(.~Species)
Or, in one graph:
ggplot(ddf)+geom_point(aes(Size, Conc., color=Place,shape=Species), size=5)