title: 3D Plotting in R - Using a 4th dimension of color
body: <p>I am using the plot3d function to make a 3d plot in my R script. I'd like to add a 4th dimension, which will be color. How can I do this?</p>
  
  <p>Specifically, assume I have the following code:</p>
  
  <pre><code>plot3d(x, y, z, col=cols, size=2, type='s')
  </code></pre>
  
  <p>how would I populate <code>cols</code> based on a vector of values acting as my 4th dimension.</p>