title: Error in UseMethod("summarise") : no applicable method for 'summarise' applied to an object of class "Date"
body: <p>I'm trying to analyse data with dates.</p>
  <p>Here is the code for my data:</p>
  <pre><code>structure(list(id = c(1L, 1L, 1L, 2L, 2L, 2L, 6L, 6L, 6L, 6L, 6L, 6L), drug = c(&quot;b&quot;, &quot;b&quot;, &quot;c&quot;, &quot;b&quot;, &quot;b&quot;, &quot;c&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;b&quot;), hospital = c(142953L, 142953L, 142953L, 12035L, 12035L, 12035L, 133163L, 133163L, 133163L, 133163L, 133163L, 133163L), start_date.y = structure(c(12173, 12204, 12753, 12311, 12341, 12400, 12877, 12907, 12938, 13091, 13121, 13152), class = &quot;Date&quot;), total.price = c(100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L, 100L), Diff = c(89L, 31L, 549L, 0L, 30L, 59L, 31L, 30L, 31L, 153L, 30L, 31L), discontinuation = c(&quot;0&quot;, &quot;0&quot;, &quot;1&quot;, &quot;0&quot;, &quot;0&quot;, &quot;0&quot;, &quot;0&quot;, &quot;0&quot;, &quot;0&quot;, &quot;1&quot;, &quot;0&quot;, &quot;0&quot;)), class = c(&quot;grouped_df&quot;, &quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;), row.names = c(NA, -12L), groups = structure(list(id = c(1L, 2L, 6L), .rows = structure(list(1:3, 4:6, 7:12), ptype = integer(0), class = c(&quot;vctrs_list_of&quot;, &quot;vctrs_vctr&quot;, &quot;list&quot;))), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;), row.names = c(NA, -3L), .drop = TRUE))
  </code></pre>
  <p>What I'm trying to calculate is the start date and end date of the drug prescriptions for each id.<br />
  First, I grouped data by &quot;id&quot; and &quot;drug&quot; variables.</p>
  <ul>
  <li>If the variable 'discontinuation' ==1, the person's end date will be the discontinuation date.</li>
  <li>If the variable 'discontinuation' == 0, the person's end date will be the last date of the prescriptions(max(start_date)).</li>
  </ul>
  <p>I tried to calculate this by the code below.</p>
  <pre><code>bio_exp_dc &lt;-bio_exp_dc %&gt;% group_by(id) %&gt;% summarise(start=min(start_date.y,na.rm = TRUE),end= ifelse(discontinuation==1,start_date.y,max(start_date.y))) 
  </code></pre>
  <p>However, the following error occured:</p>
  <pre><code>&gt;Error in UseMethod(&quot;summarise&quot;) :   
    no applicable method for 'summarise' applied to an object of class &quot;Date&quot;   
  In addition: Warning message:   
  In min.default(c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,  :
    no non-missing arguments to min; returning Inf  
  </code></pre>