title: R Plotly: how to order pie chart?
body: <p>I'm using the <code>plotly</code> package in R to build an R Shiny dashboard. I want to order my pie chart in a custom order (non-alphabetic, non-descending/ascending order). For some reason I can't find how to achieve this. </p>
  
  <p>Help would be highly appreciated!</p>
  
  <pre><code># Get Manufacturer
  mtcars$manuf &lt;- sapply(strsplit(rownames(mtcars), " "), "[[", 1)
  
  df &lt;- mtcars %&gt;%
    group_by(manuf) %&gt;%
    summarize(count = n())
  
  # Create custom order
  customOrder &lt;- c(df$manuf[12:22],df$manuf[1:11])
  
  # Order data frame
  df &lt;- df %&gt;% slice(match(customOrder, manuf))
  
  # Create factor
  df$manuf &lt;- factor(df$manuf, levels = df[["manuf"]])
  
  # Plot
  df %&gt;% plot_ly(labels = ~manuf, values = ~count) %&gt;%
    add_pie(hole = 0.6) %&gt;%
    layout(title = "Donut charts using Plotly",  showlegend = F,
           xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
           yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
  </code></pre>