-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_forecast_panel.R
60 lines (48 loc) · 2.16 KB
/
update_forecast_panel.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
setwd("/home/onno/open-fp/")
setwd("~/Git/open-fp/")
setwd("E:/Git/open-fp/")
library("readr")
library("haven")
library("dplyr")
library("foreach")
library("RCurl")
library("readxl")
library("tidyr")
library("foreign")
#library("doParallel")
dir.create("Submissions")
dir.create("temp")
dir.create("Submissions/SPF-ECB/")
dir.create("Submissions/SPF-US/")
source("update_SPF_ECB.R")
source("update_SPF_US.R")
all.joined <- full_join( forecast.panel.SPF.ECB, forecast.panel.SPF.US)
all.joined.reduced <- all.joined %>% select(panel, panel.id, variable, region, point.forecast, fixed.event.or.horizon,
issued.year, issued.quarter, years.ahead, quarters.ahead, target.year,
target.quarter)
# forecast subpanel for frontpage
forecast.panel.frontpage <- all.joined.reduced %>%
select(issued.year, issued.quarter, fixed.event.or.horizon, target.year, point.forecast, region, variable) %>%
filter(fixed.event.or.horizon == "event") %>%
dplyr::filter(issued.year > 2014) %>%
#filter(issued.quarter == 1) %>%
filter(target.year == 2015 | target.year == 2016 | target.year == 2017 | target.year == 2020) %>%
filter(is.na(point.forecast) == FALSE)
rm(all.joined.reduced)
write_rds(forecast.panel.frontpage, path = "ShinyApps/frontpage/data/forecast_panel_frontpage.rds")
rm(forecast.panel.frontpage, forecast.panel.SPF.US, forecast.panel.SPF.ECB)
write_rds(all.joined, path = "forecast.panel.rds")
#
# code for saving into the right directories
#
library(dplyr)
library(readr)
library(foreign)
forecast.panel <- read_rds(path = "~/open-fp/forecast.panel.rds") %>% filter(panel == "SPF-US")
# Create various data formats
write_csv(forecast.panel, path = "/var/www/open-fp/data/forecast.panel.csv")
write_rds(forecast.panel, path = "/var/www/open-fp/data/forecast.panel.rds")
write.dta(forecast.panel, file = "/var/www/open-fp/data/forecast.panel.dta")
write_csv(forecast.panel, path = "/home/onno/open-fp/open-fp/data/forecast.panel.csv")
write_rds(forecast.panel, path = "/home/onno/open-fp/open-fp/data/forecast.panel.rds")
write.dta(forecast.panel, file = "/home/onno/open-fp/open-fp/data/forecast.panel.dta")