Commit df9a69a8 authored by Mateo CAICEDO's avatar Mateo CAICEDO

bug fixed in the tables, because of date format.

parent ba376523
......@@ -159,9 +159,9 @@ chain <- function(to_rebase, basis, date_chain) {
group_by(var) %>%
mutate(growth_rate = c(1, value[-1]/lag(value)[-1])) %>%
full_join(valref, by = "var") %>%
ungroup() %>%
transmute(var,period, value = cumprod(growth_rate)*values_ref)
group_by(var)%>%
transmute(period, value = cumprod(growth_rate)*values_ref)%>%
ungroup()
res %<>%
bind_rows(filter(basis, period > date_chain)) %>%
......@@ -344,13 +344,12 @@ df <- rdb(ids="ECB/MIR/M.U2.B.A2A.A.R.A.2240.EUR.N")
varname <- unique(as.character(df$series_name))
lendingrate_recent <- df %>%
mutate(year = substr(period,1,4),
month = substr(period,6,7),
period= as.Date(as.yearqtr(paste0(year,"-",month,"-","01"),format="%Y-%m-%d"))) %>%
select(period, value) %>%
select(period, value) %>%
mutate(period=paste(year(period),quarter(period))) %>%
group_by(period) %>%
summarize(value=mean(value)) %>%
mutate(var= "lendingrate")
mutate(var= "lendingrate",
period=yq(period))
dataplot <- bind_rows(data.frame(lendingrate_recent,ind="recent"),
data.frame(lendingrate_old,ind="old"))
......@@ -402,14 +401,12 @@ df <- rdb(ids="ECB/IRS/M.I8.L.L40.CI.0000.EUR.N.Z")
varname <- unique(as.character(df$series_name))
longrate_recent <- df %>%
mutate(year = substr(period,1,4),
month = substr(period,6,7),
period= as.Date(as.yearqtr(paste0(year,"-",month,"-","01"),format="%Y-%m-%d"))) %>%
select(period, value) %>%
select(value, period) %>%
mutate(period=paste(year(period),quarter(period))) %>%
group_by(period) %>%
summarize(value=mean(value)) %>%
mutate(var= "longrate")
mutate(var= "longrate",
period=yq(period))
dataplot <- bind_rows(data.frame(longrate_recent,ind="recent"),
data.frame(longrate_old,ind="old"))
......@@ -497,8 +494,6 @@ EA_Finance_data <- bind_rows(loans_nfc,
longrate,
networth,
houseprice)
EA_Finance_data %<>%
mutate(period=gsub(" ", "", as.yearqtr(period)))
```
We can check the last date available for each variable.
......@@ -512,10 +507,10 @@ maxDate
```{r}
minmaxDateFinance <- min(as.yearqtr(maxDate$maxdate))
minmaxDateFinance <- min(maxDate$maxdate)
EA_Finance_data %<>%
filter(period <= minmaxDateFinance)
filter(period<=minmaxDateFinance)
```
So we filter the database until `r as.yearqtr(minmaxDateFinance)`.
......@@ -560,9 +555,9 @@ We eventually want to build a database similar to the [@Chri14a] database, but f
# Import EA_SW_rawadata.csv in wide format
EA_SW_rawdata <-
read.csv("http://shiny.nomics.world/data/EA_SW_rawdata.csv") %>%
mutate(period = gsub(" ","",as.yearqtr(period)))
read.csv("http://shiny.nomics.world/data/EA_SW_rawdata.csv")%>%
mutate(period=ymd(period))
minmaxDateRaw <- max(as.yearqtr(EA_SW_rawdata$period))
# Transform EA_SW_rawdata in long format to bind with EA_Finance_data
......@@ -571,9 +566,10 @@ EA_CMR_rawdata <-
gather(var, value, -period) %>%
bind_rows(EA_Finance_data) %>%
filter(#time <= min(minmaxDateRaw,minmaxDateFinance),
period >= "1980Q1") %>%
period >= "1980-01-01") %>%
spread(key = var, value = value)
EA_CMR_rawdata %>%
write.csv("EA_CMR_rawdata.csv", row.names=FALSE)
```
......@@ -582,7 +578,7 @@ Then data are normalized by capita and price if needed. Eventually we have 14 se
```{r}
EA_CMR_data <-
EA_CMR_rawdata %>%
transmute(period=period,
transmute(period=gsub(" ", "", as.yearqtr(period)),
gdp_rpc=1e+6*gdp/(pop*1000),
conso_rpc=1e+6*conso/(pop*1000),
inves_rpc=1e+6*inves/(pop*1000),
......@@ -624,7 +620,7 @@ listVar <- list("Real GDP per capita" = "gdp_rpc",
```{r, fig.align="center", fig.height=8.5, fig.width=8}
plot_EA_CMR_data <- EA_CMR_data %>%
gather(var, value, - period)
gather(var, value, -period)
plot_EA_CMR_data$period <- as.Date(as.yearqtr(plot_EA_CMR_data$period))
plot_EA_CMR_data$var <- as.factor(plot_EA_CMR_data$var)
levels(plot_EA_CMR_data$var)<-listVar
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment