ggplot2: Factor for x axis with geom_line doesn't work
<p>I want a line plot, where <code>value</code> is plotted as a function of <code>expt</code> with one line per level in <code>var</code>:</p>

<p>Here is my data:</p>

<pre><code>lines &lt;- "
expt,var,value
1,none.p,0.183065327746799
2,none.p,0.254234138384241
3,none.p,0.376477571234912
1,male.p,-1.58289835719949
2,male.p,-1.98591548366901
3,male.p,-2.02814824729229
1,neutral.p,-2.01490302054226
2,neutral.p,-1.88178562088577
3,neutral.p,-1.68089687641625
1,female.p,-3.27294304613848
2,female.p,-3.07711187982237
3,female.p,-2.89652562347054
1,both.p,-2.40011011312792
2,both.p,-2.24495598015741
3,both.p,-2.78501124223834"
con &lt;- textConnection(lines)
data &lt;- read.csv(con)
close(con)
</code></pre>

<p><code>expt</code> is a factor:</p>

<pre><code>data$expt &lt;- factor(data$expt)
</code></pre>

<p>Everything works as expected when I use <code>geom_point</code></p>

<pre><code>ggplot(data, aes(expt, value, colour=var)) + geom_point()
</code></pre>

<p>but when I use <code>geom_line</code></p>

<pre><code>ggplot(data, aes(expt, value, colour=var)) + geom_line()
</code></pre>

<p>I get the following error message</p>

<pre><code>geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?
</code></pre>

<p>and an empty plot.  When <code>expt</code> is numeric, it works but I prefer to use a factor because that gives me the correct labels on the x-axis.  What's the problem here?  I find it very counter-intuitive that this works with points but not with lines. </p>