## FORECAST TODO fakeToday <- as.Date('2014-06-29') loadFromForecastingJesus(fakeToday, over=TRUE) loadFromJesus("FORECASTS") DT.cleaned GL_net_forDSOM GL_gross_forDS GL_gross_forDSOM DT.net_ratios <- DT.cleaned[date %in% DT.GL_forecasted$date, list(net_to_gross_ratio=GL_net_forDSOM / GL_gross_forDS), keyby = kCols.smry] # merge(DT.GL_forecasted, DT.net_ratios, by=kCols.datestore, all=TRUE, allow=TRUE) DT.GL_forecasted.merged <- merge(DT.GL_forecasted, DT.net_ratios, by=kCols.datestore, all=TRUE, allow=TRUE) forecastCols <- c("forecasted_value", "forecasted_lo80", "forecasted_lo95", "forecasted_hi80") for (col in forecastCols) DT.GL_forecasted.merged[, paste0("net_", col) := get(col) * net_to_gross_ratio] DT.GL_forecasted.merged[, (forecastCols) := NULL] ------ WHAT IS THIS ------ > unique(merge(DT.GL_forecasted, DT.net_ratios, by=kCols.datestore, all=TRUE, allow=TRUE)[is.na(nana)][, kCols.store, with=FALSE])[order(store_name)] storeid store_name 1: 292 Avex Marketing 2: 29 Secury Cast 3: 8 Sony Connect 4: -1 zz_Delivery 5: -1 zz_Other 6: -1 zz_Performance Royalty 7: -1 zz_Physical 8: -1 zz_Publishing Services 9: -1 zz_Synch > DT.GL_forecasted[is.na(storeid)] date storeid store_name forecasted_value forecasted_lo80 forecasted_lo95 forecasted_hi80 forecasted_hi95 fakeToday fakeToday.GL 1: 2014-07-01 NA Apach Network 1317.2595 -1147.346 -2452.029 3781.865 5086.548 2014-08-18 2014-06-01 2: 2014-07-01 NA Breakage 331760.3700 NA NA NA NA 2014-08-18 2014-06-01 3: 2014-07-01 NA DMX 38.5322 -132.514 -223.060 209.578 300.124 2014-08-18 2014-06-01 4: 2014-07-01 NA FunMobility 114.4624 -186.594 -345.964 415.519 574.889 2014-08-18 2014-06-01 5: 2014-07-01 NA Gee Beyond Holdings 14882.6428 -16527.397 -33154.867 46292.682 62920.153 2014-08-18 2014-06-01 6: 2014-07-01 NA J/E Adjustments -41732.4248 -386916.405 -569645.767 303451.556 486180.917 2014-08-18 2014-06-01 7: 2014-07-01 NA Liberator Music 761.0089 -1895.841 -3302.293 3417.859 4824.311 2014-08-18 2014-06-01 8: 2014-07-01 NA MOG (Mobile) AU Only 18822.2933 -52267.403 -143392.038 89911.990 181036.624 2014-08-18 2014-06-01 9: 2014-07-01 NA Rightscorp 110.9501 -270.707 -472.745 492.608 694.645 2014-08-18 2014-06-01 10: 2014-07-01 NA Shamrock 1269.9979 -991.564 -2188.763 3531.560 4728.759 2014-08-18 2014-06-01 11: 2014-07-01 NA TIM Muve (Brazil) 13998.1983 -3386.483 -12589.378 31382.880 40585.774 2014-08-18 2014-06-01 12: 2014-07-01 NA iTunes 235004.8700 NA NA NA NA 2014-08-18 2014-06-01 13: 2014-08-01 NA Apach Network 1317.2595 -1147.346 -2452.029 3781.865 5086.548 2014-08-18 2014-06-01 14: 2014-08-01 NA Breakage 331760.3700 NA NA NA NA 2014-08-18 2014-06-01 15: 2014-08-01 NA DMX 38.5322 -132.514 -223.060 209.578 300.124 2014-08-18 2014-06-01 16: 2014-08-01 NA FunMobility 114.4624 -186.594 -345.964 415.519 574.889 2014-08-18 2014-06-01 17: 2014-08-01 NA Gee Beyond Holdings 14882.6428 -16527.399 -33154.871 46292.685 62920.156 2014-08-18 2014-06-01 18: 2014-08-01 NA J/E Adjustments -41732.4248 -386916.407 -569645.769 303451.557 486180.920 2014-08-18 2014-06-01 19: 2014-08-01 NA Liberator Music 761.0089 -1895.841 -3302.293 3417.859 4824.311 2014-08-18 2014-06-01 20: 2014-08-01 NA MOG (Mobile) AU Only 18822.2933 -52267.403 -143392.038 89911.990 181036.624 2014-08-18 2014-06-01 21: 2014-08-01 NA Rightscorp 110.9501 -270.707 -472.745 492.608 694.645 2014-08-18 2014-06-01 22: 2014-08-01 NA Shamrock 1269.9979 -991.564 -2188.763 3531.560 4728.759 2014-08-18 2014-06-01 23: 2014-08-01 NA TIM Muve (Brazil) 13998.1983 -3386.483 -12589.378 31382.880 40585.774 2014-08-18 2014-06-01 24: 2014-08-01 NA iTunes 235004.8700 NA NA NA NA 2014-08-18 2014-06-01 date storeid store_name forecasted_value forecasted_lo80 forecasted_lo95 forecasted_hi80 forecasted_hi95 fakeToday fakeToday.GL > DT.GL_forecasted[-1 == (storeid)] Empty data.table (0 rows) of 10 cols: date,storeid,store_name,forecasted_value,forecasted_lo80,forecasted_lo95... >