rearranging axis labels in Plotly R
<p>I have the following data frame:</p>

<pre><code>structure(list(Var1 = structure(1:7, .Label = c("Friday", "Monday", 
"Saturday", "Sunday", "Thursday", "Tuesday", "Wednesday"), class = "factor"), 
    Freq = c(20938L, 43147L, 35027L, 24087L, 7148L, 6310L, 19027L
    )), .Names = c("Var1", "Freq"), row.names = c(NA, -7L), class = "data.frame")
</code></pre>

<p>It looks like this:</p>

<pre><code>       Var1  Freq
1    Friday 20938
2    Monday 43147
3  Saturday 35027
4    Sunday 24087
5  Thursday  7148
6   Tuesday  6310
7 Wednesday 19027
</code></pre>

<p>when I plot it using plotly library, the x-axis starts from Wednesday and goes all the way up to Friday.  But I want to reorder the labels starting from Sunday to Saturday.  I use the following codes:</p>

<p>Assuming 't' is the data frame with data given above:</p>

<pre><code>target &lt;- c("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
a &lt;- t[match(target, t$Dayoftheweek), ]
plot_ly(a, x = Dayoftheweek, y = Freq, type = "bar", color = Dayoftheweek) 
</code></pre>

<p>This doesn't work. I have reset the rownames to null still the same problem occurs.</p>