title: How do I make a categorical variable on x-axis of ggplot geom_line with multiple groups
body: <p>I'm starting with</p>
  
  <pre class="lang-r prettyprint-override"><code>&gt;df57 &lt;- data.frame(cellType = c("4.57", "4.57", "8.57", "8.57", "8.28.57", "8.28.57"), 
                          ORR = c("PD", "nonPD"),
                          BL = rep(0, each=6), 
                          Treated = c(10, -5, 8, -4, 15, -2))
  &gt;df57melt &lt;- melt(df57)
  &gt;df57melt
  
  cellType    ORR variable  value
  1   4.57    PD      BL      0
  2   4.57    nonPD   BL      0
  3   8.57    PD      BL      0
  4   8.57    nonPD   BL      0
  5   8.28.57 PD      BL      0
  6   8.28.57 nonPD   BL      0
  7   4.57    PD      Treated 10
  8   4.57    nonPD   Treated -5
  9   8.57    PD      Treated 8
  10  8.57    nonPD   Treated -4
  11  8.28.57 PD      Treated 15
  12  8.28.57 nonPD   Treated -2                        
  </code></pre>
  
  <p>I want to make a line plot in which treatment is on the x-axis (BL, Treated) and value on the y-axis (continuous). I want to have three cell types (4.57, 8.57, and 8.28.57; I want coded by line color) that each have response variable (PD and nonPD; I want coded by line style). </p>
  
  <p>I plot what I think should work:</p>
  
  <pre class="lang-r prettyprint-override"><code>&gt;ggplot(data=df57melt, aes(x=variable, y = value)) + 
    geom_line(aes(linetype = ORR, color = cellType))
  
  geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?
  
  #so I add group info
  &gt;ggplot(data=df57melt, aes(x=variable, y = value, group = cellType)) + 
    geom_line(aes(linetype = ORR, color = cellType))
  
  Error: geom_path: If you are using dotted or dashed lines, colour, size and linetype must be constant over the line
  
  #but if I change from categorical x to continuous x...
  &gt;ggplot(data=df57melt, aes(x=as.numeric(variable), y = value)) + 
    geom_line(aes(linetype = ORR, color = cellType))
  </code></pre>
  
  <p>And it gives me something like what I want...but not quite 
  <a href="https://i.stack.imgur.com/naXTf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/naXTf.png" alt="Line plot"></a>
  How do I get it to recognize my x as categorical?</p>