Why won't dplyr's top_n() work?
<p>I have a dataframe called <code>df</code>:</p>

<pre><code>City,State,Price,Dogs
Portland,OR,75,1
Portland,OR,100,3
San Diego,CA,12,4
San Diego,CA,23,5
...
</code></pre>

<p>I used <code>dplyr</code>'s <code>summarise</code> and <code>group_by</code> functions...</p>

<pre><code>df.median &lt;- summarise(
  group_by(
    df, 
    State, 
    City
  ),
  MEDIAN_PRICE = median(Price),
  SUM_DOGS = sum(Dogs)
)
</code></pre>

<p>But when I run <code>top_n(df.median, 100, SUM_DOGS)</code>, R does not give me cities with the 100 highest values in <code>SUM_DOGS</code>. It just returns <code>df.median</code>.</p>

<p>Why?</p>