title: R rbind during loop
body: <p>This code works for everything... except the rbind part at the end. I want to take the results from the loop and combine them into one forecast data frame. I tried to create an empty temp data frame (I am forecasting 12 quarters) but I get a "not equally sized" error.</p>
  
  <p>Can someone help me out? I'm almost there :-)</p>
  
  <pre><code># Create actual data frame
  Data_act &lt;- subset(Data,Data$Type=="Actual")
  
  # Create forecast frame with descriptive columns
  Data_fc &lt;- subset(Data[1:5],Data$Type=="Forecast")
  
  # Create empty data frame for forecast results
  Data_fc2 &lt;- subset(Data[,6:9],Data$Type=="Forecast")
  Data_fc2 &lt;- Data_fc2[1:12,]
  Data_fc3 &lt;- Data_fc2 # temp table for loop
  
  # Create list of unique forecast names
  UniqueList &lt;- unique(Data_act$forecast_name)
  
  # Loop through unique list of forecast names
  for(i in 1:length(UniqueList)){
  
      # Subset data for forecast name
      df &lt;- subset(Data_act,Data_act$forecast_name==UniqueList[i])
  
      # Create time series objects
      dftsunits &lt;- ts(df$Units,start = c(2015,1),frequency = 4)
      dftsasp &lt;- ts(df$ASP,start = c(2015,1),frequency = 4)
  
      # Train forecasting models (Holt-Winters and ARIMA)
      FC_Units_HW &lt;- hw(dftsunits,h=12)
      FC_Units_Arima &lt;- auto.arima(dftsunits,lambda = 0) #lambda = 0 prevents     negative forecasts
      FC_ASP_HW &lt;- hw(dftsasp,h=12)
      FC_ASP_Arima &lt;- auto.arima(dftsasp,lambda = 0)
  
      # Forecast models for 12 quarters
      FC_Units_HW2 &lt;- forecast(FC_Units_HW,h=12)
      FC_Units_Arima2 &lt;- forecast(FC_Units_Arima,h=12)
      FC_ASP_HW2 &lt;- forecast(FC_ASP_HW,h=12)
      FC_ASP_Arima2 &lt;- forecast(FC_ASP_Arima,h=12)
  
      # Save results
      Data_fc3$Units_HW &lt;- FC_Units_HW2$mean
      Data_fc3$Units_ARIMA &lt;- FC_Units_Arima2$mean
      Data_fc3$ASP_HW &lt;- FC_ASP_HW2$mean
      Data_fc3$ASP_ARIMA &lt;- FC_ASP_Arima2$mean
  
      # Add results to master result data frame
      Data_fc2 &lt;= rbind(Data_fc2,Data_fc3)
  }
  </code></pre>