title: Combining multiple data.frame in R?
body: <p>I am computing <code>statistics</code> (i.e., mean, max, median etc) for <code>winter season</code> comprised of Months 11 &amp; 12 of <code>previous year</code> and Months 1-4 of <code>following year</code>.</p>
  
  <pre><code>mydate &lt;- as.data.frame(seq(as.Date("2010-01-01"), to= as.Date("2019-12-31"), by="day"))
  colnames(mydate) &lt;- "Date"
  DF &lt;- data.frame(A = runif(3652,0,10), 
                     J = runif(3652,0,8), 
                     X = runif(3652,0,12), 
                     Z = runif(3652,0,10), 
                    mydate)
  
  mydata &lt;- DF %&gt;% mutate(Year = year(Date), Month = month(Date)) %&gt;%
    pivot_longer(-c(Date,Year,Month), names_to = "variable", values_to = "values") %&gt;% 
    filter(Month == 11 | Month == 12 | Month == 01 | Month == 02 | Month == 03 | Month == 04) %&gt;% 
    mutate(W_Year = ifelse(Month &gt; 10, Year+1, Year)) %&gt;% 
    filter(W_Year != 2019) %&gt;% 
    group_by(W_Year, variable) %&gt;% 
    mutate(Cumulative = cumsum(values)) %&gt;%
    mutate(NewDate = ymd(paste("2020", Month, day(Date), sep = "-"))) %&gt;%
    ungroup() %&gt;%
    group_by(variable, NewDate) %&gt;%
    summarise(Median = median(Cumulative))
  </code></pre>
  
  <p>I would then need to <code>combine</code> <code>mydata</code> with the <code>data.frame</code> of <code>accumulated</code> values for the most recent year, which in my case is the <code>year 2019</code> as an additional column.</p>
  
  <pre><code>X = c("A", "J","X", "Z")
  
  Data2019 &lt;- DF %&gt;% mutate(Year = year(Date), Month = month(Date)) %&gt;%
    pivot_longer(-c(Date,Year,Month), names_to = "variable", values_to = "values") %&gt;% 
    filter(between(Month,5,10)) %&gt;% 
    filter(Year == 2019) %&gt;% 
    group_by(Year, variable) %&gt;% 
    mutate(Precipitation = cumsum(values)) %&gt;%
    mutate(NewDate = ymd(paste("2020", Month,day(Date), sep = "-"))) %&gt;%
    ungroup() %&gt;%
    group_by(variable, NewDate) %&gt;%
    select(c(4,6,7)) %&gt;% 
    slice(match(X, variable))
  </code></pre>
  
  <p>While <code>combining</code> the two <code>data.frame</code>, i am getting <code>mis-match</code> error for number of rows- which i believe is due to <code>leap year</code> but do not know how to overcome this problem. Any way forward would help. Thank you,</p>
  
  <pre><code>Data_plot &lt;- data.frame(mydata, Data2019[,2])
  </code></pre>