title: Summarize data frames and add new columns
body: <p>I want to create a date range by type of weather, add a new column that gives me number of days for that weather and two more column that gives me average of temperature and then the sum of temperature from "df"</p>
  
  <pre><code>set.seed(121)
  df &lt;- data.frame( "Date" = sprintf("%02d-Jan", 1:10), "Type of Weather" = c(rep("Cloudy", 3), rep("Rainy", 2), rep("Cloudy", 4), rep("Sunny", 1)), "Average temperature"= 20:29 ) 
  </code></pre>
  
  <p>Expected output: </p>
  
  <pre><code>ndf &lt;- df[, .(Date = paste(Date[1], "to", Date[.N]), weather = Type.of.Weather[1]), rleid(Type.of.Weather) ][, rleid := NULL ][] ndf$Countofdays= c(3,2,4,1) ndf$Averagetemp=c(21,23.5,26.5,29)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/4oq30.png" rel="nofollow noreferrer">Input:</a></p>
  
  <p><a href="https://i.stack.imgur.com/7fsAP.png" rel="nofollow noreferrer">Expected output:</a></p>