title: add_trace in Plotly in a loop
body: <p><strong>I want to plot multiple traces in a loop without overwriting all previous traces.</strong></p>
  
  <p>In <a href="https://stackoverflow.com/questions/34186560/plotly-add-trace-in-a-loop">this post</a> from 2015, a solution to adding traces within a loop is presented, by setting <code>evaluate = TRUE</code> in the plot_ly or add_trace functions. However, as of 2017 in the newer version of plot_ly, <code>evaluate</code> isn't an attribute.</p>
  
  <pre><code>'scatter3d' objects don't have these attributes: 'evaluate'
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/46225342/plotly-add-trace-using-lapply-or-for-loops-doesnt-work">This question</a>, and <a href="https://stackoverflow.com/questions/38169634/optimizing-add-trace-in-a-for-loop">this question</a> also fail to answer the problem. <a href="http://www.r-graph-gallery.com/129-use-a-loop-to-add-trace-with-plotly/" rel="noreferrer">This post</a> acknowledges that evaluate = TRUE isn't doesn't work with new plotly, but doesn't give a solution. <strong>What is the new solution to this problem?</strong></p>
  
  <hr>
  
  <p>My data for copy/paste: </p>
  
  <pre><code>structure(list(x_1 = c(74.651438, 75.31493, 76.736865, 77.858125, 
  79.347856, 80.302483), y_1 = c(249.063605, 247.149121, 245.461889, 
  243.811041, 242.382685, 240.300034), z_1 = c(4.373868, 3.653744, 
  4.101455, 4.134471, 4.225507, 4.890157), x_2 = c(85.468712, 86.637469, 
  87.993127, 87.907308, 88.748766, 89.680155), y_2 = c(249.063405, 
  247.145423, 245.46148, 244.949469, 244.005001, 242.917665), z_2 = c(4.56633, 
  4.059976, 3.842906, 4.019021, 4.316799, 4.378894), x_3 = c(101.720648, 
  101.70598, 102.022836, 102.166059, 102.242424, 102.317043), y_3 = c(249.660075, 
  249.562464, 249.771452, 249.619983, 249.39349, 249.444531), z_3 = c(3.080686, 
  3.003508, 2.774651, 2.291644, 2.239727, 1.932501)), .Names = c("x_1", 
  "y_1", "z_1", "x_2", "y_2", "z_2", "x_3", "y_3", "z_3"), row.names = c(NA, 
  6L), class = "data.frame")
  </code></pre>
  
  <p>My code:</p>
  
  <hr>
  
  <pre><code>library(plotly)
  p &lt;- plot_ly(temp, type = 'scatter3d', mode = 'lines', width = 1)
  for(i in 1:3){
    x = paste0("x_",i)
    y = paste0("y_",i)
    z = paste0("z_",i)
    p &lt;- add_trace(p, x = ~get(x), y = ~get(y), z = ~get(z))
  }
  
  p
  </code></pre>