title: Plotly in R passing a variable through using a function
body: <p>I'm trying to create a ring chart using <code>plotly</code> through a function so I can change variables around.</p>
  
  <p>The following code returns <strong>no chart</strong>, but no errors either:</p>
  
  <pre><code>library(plotly)
  library(dplyr)
  
  function_ringchart&lt;- function(dataset, labvar, summvar){
  summvar_temp &lt;- enquo(summvar)
  labvar_temp &lt;- enquo(labvar)
  p&lt;- plot_ly(data = dataset, labels = ~labvar_temp, values = ~summvar_temp , type ="pie",hole = 0.6)
  p
  }
  
  function_ringchart(df, "person","msgcount")
  </code></pre>
  
  <p>The following code however works fine and <strong>returns the correct chart</strong> (without varying the values variable):</p>
  
  <pre><code>function_ringchart&lt;- function(dataset, labvar){
  #summvar_temp &lt;- enquo(summvar)
  labvar_temp &lt;- enquo(labvar)
  p&lt;- plot_ly(data = dataset, labels = ~labvar_temp, values = ~msgcount, type ="pie",hole = 0.6)
  p
  }
  
  function_ringchart(df, "person")
  </code></pre>
  
  <p>Wondering what the reason is for the first set of code not working, or how to correctly use variable inputs for the <code>values =~</code> component of <code>plot_ly</code>?</p>