title: Errors when exporting plots to Plot.ly
body: <p>I have this data (sample of the first 20 rows):</p>
  
  <ul>
  <li>Codering  variable    value   </li>
  <li>1 Z1  Week.0  0</li>
  <li>2 Z2  Week.0  0</li>
  <li>3 Z3  Week.0  0</li>
  <li>4 Z4  Week.0  0</li>
  <li>5 Z5  Week.0  0</li>
  <li>6 Z6  Week.0  0</li>
  <li>7 Z7  Week.0  0</li>
  <li>8 Z8  Week.0  0</li>
  <li>9 Z9  Week.0  0</li>
  <li>10    Z101    Week.0  NA</li>
  <li>11    Z102    Week.0  NA</li>
  <li>12    Z1  Week.1  0</li>
  <li>13    Z2  Week.1  0</li>
  <li>14    Z3  Week.1  0</li>
  <li>15    Z4  Week.1  0</li>
  <li>16    Z5  Week.1  0</li>
  <li>17    Z6  Week.1  0</li>
  <li>18    Z7  Week.1  0</li>
  <li>19    Z8  Week.1  0</li>
  </ul>
  
  <p>and I plot it using:</p>
  
  <pre><code>pZ &lt;- ggplot(zmeltdata,aes(x=variable,y=value,color=Codering,group=Codering)) + 
    geom_line()+
    geom_point()+
    theme_few()+
    theme(legend.position="right")+
    scale_color_hue(name = "Treatment group:")+
    scale_y_continuous(labels = percent)+
    ylab("Germination percentage")+
    xlab("Week number")+
    labs(title = "Z. monophyllum germination data")
  pZ
  </code></pre>
  
  <p>The graph displays just fine: </p>
  
  <p><img src="https://i.stack.imgur.com/05taL.png" alt="enter image description here"></p>
  
  <p>Yet when I want to export this to Plot.ly I get the following errors:</p>
  
  <pre><code>&gt; py &lt;- plotly()
  &gt; response&lt;-py$ggplotly(pZ)
  Error in if (all(xcomp) &amp;&amp; all(ycomp)) { : 
    missing value where TRUE/FALSE needed
  In addition: Warning message:
  In trace.list[[lind[1]]]$y == trace.list[[lind[2]]]$y :
    longer object length is not a multiple of shorter object length
  </code></pre>
  
  <p>And I have searched for these errors, yet the explanation thoroughly confuses me. "The missing value where TRUE/FALSE needed." is supposed to occur if you use logical termms as IF/ELSE/TRUE/FALSE and such in your process, which I don't at all! Even when checking for any NA's in the value of the graph I get:</p>
  
  <pre><code>&gt; is.na(pZ)
         data      layers      scales     mapping       theme coordinates       facet    plot_env      labels 
        FALSE       FALSE       FALSE       FALSE       FALSE       FALSE       FALSE       FALSE       FALSE 
  </code></pre>
  
  <p>and the 'longer object length is not multiple of shorter object length' is supposed to pop up when you have objects of different lengths, but I'm only using 1 object with 3 rows that have exactly the same length.. The value of the graph does give me a <code>NULL</code> when I ask for those rows, but that is supposed to happen..</p>
  
  <pre><code>&gt; nrow(zmeltdata)
  [1] 143
  &gt; nrow(test)
  NULL
  </code></pre>
  
  <p>All in all, I'm very confused and don't know how to correctly handle these errors, could someone elaborate?</p>
  
  <p>Thanks for your time.</p>
  
  <p>EDIT: I have tried to export a different graph to Plot.ly using a random sample of 1:100 and that worked just fine, I'm pretty sure the error is in my data, I just can't figure out how to fix it.</p>
  
  <p>EDIT2: In response to @Gregor:</p>
  
  <pre><code>&gt; dput(head(zmeltdata, 20))
  structure(list(Codering = structure(c(16L, 19L, 20L, 21L, 22L, 
  23L, 24L, 25L, 26L, 17L, 18L, 16L, 19L, 20L, 21L, 22L, 23L, 24L, 
  25L, 26L), .Label = c("B1", "C2", "C3", "C8", "M1", "M101", "M102", 
  "M2", "M3", "M4", "M5", "M6", "M7", "M8", "M9", "Z1", "Z101", 
  "Z102", "Z2", "Z3", "Z4", "Z5", "Z6", "Z7", "Z8", "Z9"), class = "factor"), 
      variable = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
      1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Week.0", 
      "Week.1", "Week.2", "Week.3", "Week.4", "Week.5", "Week.6", 
      "Week.7", "Week.8", "Week.9", "Week.10", "Week.11", "Week.12"
      ), class = "factor"), value = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 
      NA, NA, 0, 0, 0, 0, 0, 0, 0, 0, 0)), .Names = c("Codering", 
  "variable", "value"), row.names = c(NA, 20L), class = "data.frame")
  </code></pre>
  
  <p>And the tail:</p>
  
  <pre><code>&gt; dput(tail(zmeltdata, 43))
  structure(list(Codering = structure(c(19L, 20L, 21L, 22L, 23L, 
  24L, 25L, 26L, 17L, 18L, 16L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 
  26L, 17L, 18L, 16L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 17L, 
  18L, 16L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 17L, 18L), .Label = c("B1", 
  "C2", "C3", "C8", "M1", "M101", "M102", "M2", "M3", "M4", "M5", 
  "M6", "M7", "M8", "M9", "Z1", "Z101", "Z102", "Z2", "Z3", "Z4", 
  "Z5", "Z6", "Z7", "Z8", "Z9"), class = "factor"), variable = structure(c(10L, 
  10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 11L, 11L, 11L, 11L, 
  11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 12L, 12L, 
  12L, 12L, 12L, 12L, 12L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 
  13L, 13L, 13L), .Label = c("Week.0", "Week.1", "Week.2", "Week.3", 
  "Week.4", "Week.5", "Week.6", "Week.7", "Week.8", "Week.9", "Week.10", 
  "Week.11", "Week.12"), class = "factor"), value = c(0.1, 0.06, 
  0.05, 0.09, 0.04, 0.08, 0.05, 0.08, 0, 0, NA, NA, NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA)), .Names = c("Codering", 
  "variable", "value"), row.names = 101:143, class = "data.frame")
  </code></pre>
  
  <p>I am not at all surprised by these, there are quite some NA's in the dataset but they shouldn't prove to be an issue, since I have used a similar (bigger) dataset before.</p>
  
  <p>And I also have the .csv file for you to use if you wish: <a href="https://www.mediafire.com/?jij1vlp14a29ntt" rel="nofollow noreferrer">https://www.mediafire.com/?jij1vlp14a29ntt</a></p>