title: when to use factor() when plotting with ggplot in R?
body: <p>When do you normally use <code>factor</code> to color/size encode variables in ggplot2 in R? Example:</p>
  
  <pre><code>ggplot(mtcars) + geom_point(aes(x=mpg, y=drat, colour=gear))
  </code></pre>
  
  <p>versus:</p>
  
  <pre><code>ggplot(mtcars) + geom_point(aes(x=mpg, y=drat, colour=factor(gear)))
  </code></pre>
  
  <p>Is the general rule to use <code>factor</code> when the variable being used to determine the shape/size/colour is discrete, and not continuous? Or is there another use of <code>factor</code> in this context? It seems like the first command can be made like the second with the right legend, even without <code>factor</code>. thanks.</p>
  
  <p><em>edit</em>: I get this when I use the <code>colour=gear</code>:
  <img src="https://i.stack.imgur.com/tfYIT.png" alt="enter image description here"></p>