title: How does the unique function return only unique values in dataframe?
body: <p>I have dataframe, which I want to filter the amount container of container at each station at a given time with respect to the container type. The data used contain the release and receive date, the arrival station, the unique container code and the container type. One line of the dataframe is one movement.</p>
  
  <pre><code>library(dplyr)
  library(tidyverse)
  library(lubridate)
  
  release.date &lt;- as_date(c("2017-12-15","2018-05-31", "2017-03-03", "2017-11-16", "2017-10-15", "2017-12-22", "2017-12-02"))
  receive.date &lt;- as_date(c("2018-12-15","2018-08-31", "2017-09-03", "2017-12-16", "2017-11-15", "2017-12-24", "2017-12-02"))
  
  Routen2 &lt;- data.frame(release.date, receive.date, destination.station = c("New York", "London", "New York", "London", "New York", "New York", "New York"), container.code = c("A1", "B2", "B1", "B1", "B4", "B3", "A1"), container.type = c("a", "b", "b", "b", "b", "b", "a"))
  </code></pre>
  
  <p>The idea is to filter every movement, that starts after the deadline (2017.12.31). Then order the it after the release date and use the unique function to get only the newest movement of each individual container, that happened before the deadline. Afterwards filter the the receive date for the deadline to eliminate container still in traffic. And finally get the count at the stations with the container types.</p>
  
  <pre><code>Routen2 %&gt;%
    filter(release.date &lt;= "2017-12-31") %&gt;%
    .[order(.$release.date),] %&gt;%
    .[unique(.$container.code, fromLast = TRUE),] %&gt;%
    filter(receive.date &lt;= "2017-12-31") %&gt;%
    count(destination.station, container.type)
  </code></pre>
  
  <p>The result should look like this:</p>
  
  <blockquote>
  <pre><code>  destination.station container.type     n  
  1 New York            a                  1  
  2 New York            b                  2  
  3 London              b                  1
  </code></pre>
  </blockquote>
  
  <p>In this sample data the Result lacks London completely. The container.code is not unique after the unique function (When the script is run without the last two lines). Why does it not work?</p>