Commit 08677294 authored by Thomas Brand's avatar Thomas Brand

Remove facetadjust function.

parent 37f31140
......@@ -631,60 +631,6 @@ EA_CMR_data %>%
write.csv("EA_CMR_data.csv", row.names=FALSE)
```
```{r echo=FALSE}
# http://stackoverflow.com/questions/13297155/add-floating-axis-labels-in-facet-wrap-plot/13316126#13316126
# pos - where to add new labels
# newpage, vp - see ?print.ggplot
facetAdjust <- function(x, pos = c("up", "down"),
newpage = is.null(vp), vp = NULL)
{
# part of print.ggplot
ggplot2:::set_last_plot(x)
if(newpage)
grid.newpage()
pos <- match.arg(pos)
p <- ggplot_build(x)
gtable <- ggplot_gtable(p)
# finding dimensions
dims <- apply(p$panel$layout[2:3], 2, max)
nrow <- dims[1]
ncol <- dims[2]
# number of panels in the plot
panels <- sum(grepl("panel", names(gtable$grobs)))
space <- ncol * nrow
# missing panels
n <- space - panels
# checking whether modifications are needed
if(panels != space){
# indices of panels to fix
idx <- (space - ncol - n + 1):(space - ncol)
# copying x-axis of the last existing panel to the chosen panels
# in the row above
gtable$grobs[paste0("axis_b",idx)] <- list(gtable$grobs[[paste0("axis_b",panels)]])
if(pos == "down"){
# if pos == down then shifting labels down to the same level as
# the x-axis of last panel
rows <- grep(paste0("axis_b\\-[", idx[1], "-", idx[n], "]"),
gtable$layout$name)
lastAxis <- grep(paste0("axis_b\\-", panels), gtable$layout$name)
gtable$layout[rows, c("t","b")] <- gtable$layout[lastAxis, c("t")]
}
}
# again part of print.ggplot, plotting adjusted version
if(is.null(vp)){
grid.draw(gtable)
}
else{
if (is.character(vp))
seekViewport(vp)
else pushViewport(vp)
grid.draw(gtable)
upViewport()
}
invisible(p)
}
```
```{r echo=FALSE}
listVar <- list("Real GDP per capita" = "gdp_rpc",
......@@ -719,7 +665,7 @@ p <- ggplot(plot_EA_CMR_data,aes(time,values))+
theme(strip.text=element_text(size=10),
axis.text=element_text(size=9))+
ggtitle("CMR data for the Euro area")
facetAdjust(p)
p
```
You can also download ready-to-use (normalized) data for the estimation on Dynare <a href="http://shiny.obsmacro.org/data/EA_CMR_data.csv" target="_blank">here</a>.
......
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