I have a data matrix in the form of:
x y z
1 A T
1.5 B T
2 A T
5 B T
7 A T
... and so on. So my x is a continuous variable, and y a factor (A or B), and z a factor (of only 1 level T). Now I want to draw a boxplot of variable x, and lay on top each data point coloured by y.
ggplot(data, aes(x=z, y=x)) + geom_boxplot() + geom_point(aes(colour = data$y))
Since my dataset is bigger than the example above, I have a lot of overlaying dots that are coloured. Therefore I would like to position the data points for each factor (y) next to each other, so that the data points for the factors don't overlap (the data points within a factor can of course). How do I do that?