Using ggplot2 to create a line chart showing spread between two variables in each observation

Viewed 246

Here's my data:

   Assignment first Stage  Grade Type
1        PA06  98.5 final  98.50   PA
2        PA06  98.5 final  98.50   PA
3        PA06  83.0 final  83.00   PA
4        PA06 100.0 final 100.00   PA
5        PA06 100.0 final 100.00   PA
6        PA06  98.5 final  98.50   PA
7        PA06  86.0 final  86.00   PA
8        PA06 100.0 final 100.00   PA
9        PA06  84.5 final  88.00   PA
10       PA06  95.0 final  95.00   PA
11       PA06  83.0 final  90.00   PA
12       PA06   0.0 final   6.75   PA

I am thinking that I want a chart with observations along the x axis, showing a vertical line starting at "first" and ending at "Grade".

Notice that often first and Grade will be equal and in that case I get just a dot. Otherwise I get a line with dots at each end. And I want no labels on the x axis.

This may be a little odd, but I am experimenting with my data. I think it should be "easy" but I can't seem to get it. Here's what I've tried so far:

ggplot(x2, aes(x=first, y=Grade)) + geom_line()
ggplot(x2, aes(x=email)) + geom_point(aes(y=Grade, col="blue")) + geom_point(aes(y=first, col="red"))
2 Answers
Related