Shiny validate not working on zero row data frame?
<p>I have the following code....for some reason, <code>validate</code> does not kick in and the <code>plot</code> command runs with an error. What am I missing?</p>

<pre><code>library(shiny)
df &lt;- data.frame(x = 1, y = 1)

ui &lt;- fluidPage(
  plotOutput('plot')
)

server &lt;- function(input, output) {
  output$plot &lt;- renderPlot({
    df &lt;- df[-1, ]
    validate(
      need(nrow(df),
           "Not Enough Data")
    )
    plot(df$x, df$y)
  })
}

shinyApp(ui = ui, server = server)
</code></pre>

<p>Everything from the data frame perspective looks fine:</p>

<pre><code>df &lt;- data.frame(x = 1, y = 1)
df
  x y
1 1 1

df &lt;- df[-1, ]
df
[1] x y
&lt;0 rows&gt; (or 0-length row.names)

nrow(df)
[1] 0

names(df)
[1] "x" "y"
</code></pre>