Reputation: 523
I have a dataframe which looks like this:
da <- data.frame("a"=c(1,2.5,3,4.5,4),"b"=c(1.5,2.7,3.2,4.7,4.2))
a b
1 1.0 1.5
2 2.5 2.7
3 3.0 3.2
4 4.5 4.7
5 4.0 4.2
I want to plot the above values for a
and b
where labels on the x axis are a
and b
while ylim ranges from 0 to 10. So basically all the values of a
should be plotted parallel to yaxis and then some distance apart, values of b
should be plotted parallel to yaxis. I tried using the plot function but cannot get it to work. Any help would be appreciated.
Upvotes: 1
Views: 343
Reputation: 28825
library(tidyr)
library(ggplot2)
ggplot(data = gather(da, category, value), aes(x=category, y=value)) +
geom_point() +
ylim(0,10)
Upvotes: 1