Plotting multiple columns with ggplot2
I need to plot the following dataset in the same graph.
Bin1,Bin2,Bin3,Cat 4,3,5,S 6,4,5,M 3,5,4,M 1,4,5,M ,5, ,M
In each bin, first data point belongs to a different category than the rest. (So I added the Cat column)
I need to plot these as points (different colors for the different categories)
Following lines of code achieve what I need for a single bin
p <- ggplot(data,aes(Bin1,1)) p + geom_point(aes(color=Cat, size=Cat))
How do I do this for the entire dataset ?
Here is a related question?
What if I need to use a bunch of columns to color the points. Color Bin1 points according to Cat1 and so on..
Bin1,Cat1,Bin2,Cat2 4,S,5,S 6,L,5,M 3,M,4,L 1,M,5,L 3,M
How do I do this??
library(reshape2) library(ggplot2) ggplot(melt(df, id.vars = "Cat"), aes(value, variable, colour = Cat)) + geom_point(size = 4)