title: R 3d plot with categorical colors
body: <p>I have 4 columns of data in R that looks like this</p>
  
  <pre><code>x   y   z  group
  </code></pre>
  
  <p>the <code>group</code> columns has categorical values, so it is a discrete set of values, whereas the other three columns are continuous.</p>
  
  <p>I want to make a 3d plot in R with <code>x</code>, <code>y</code>, and <code>z</code>, and where the color of the dot is given by "group". I also want to have a legend to this plot. How can I do this? I don't have a particular preference on the actual colors. I suppose <code>rainbow(length(unique(group))</code> should do fine.</p>