title: How can I mark (flag) first unique record as 1 and the rest similar records as 0 in data frame in R
body: <p>I need help with my data in R. I will create new column if I have at least one record.
  My data (df) look like this:</p>
  <pre><code>date adress
  28.03 bla
  28.03 xyz
  17.03 abc
  30.03 yxz
  24.03 bla 
  17.03 abc
  23.03 abc
  28.03 bla
  24.03 bla
  24.03 bla
  </code></pre>
  <p>And I want to create new column with driving, where if date is the same and adress too then set 1 (in first spotted record). If someone goes another time (date) in the same place, set 1, but if someone go to the same place and date will be again the same set 0.<br />
  Sth like this:</p>
  <pre><code>date adress drive
  28.03 bla 1
  28.03 xyz 1
  17.03 abc 1
  30.03 yxz 1
  24.03 bla 1 
  17.03 abc 0
  23.03 abc 1
  28.03 bla 0
  24.03 bla 0
  24.03 bla 0
  </code></pre>
  <p>I use dplyr:</p>
  <pre><code>df2 &lt;- df %&gt;%
         group_by(date, adress) %&gt;%
         mutate(drive = ifelse(n()&gt;1, 0, 1))
  </code></pre>
  <p>I get data as below and my first spotted record has also 0.</p>
  <pre><code>date adress drive
  28.03 bla 0
  28.03 xyz 1
  17.03 abc 0
  30.03 yxz 1
  24.03 bla 0 
  17.03 abc 0
  23.03 abc 1
  28.03 bla 0
  24.03 bla 0
  24.03 bla 0
  </code></pre>
  <p>Any has some idea?</p>