knitr::opts_chunk$set(echo = FALSE)
knitr::read_chunk("../../R/tool.R")
knitr::read_chunk("../../R/data.R")
knitr::read_chunk("../../R/ccze_init_table.R")
<<init>>
<<tool>>
<<data>>
setHeader(title=c("Agrégats monétaires - Zone euro","Monetary aggregates - Euro area"),
          subtitle=c("Données corrigées des effets saisonniers et de calendrier","Data adjusted for seasonal and working-day variations"))
#get data & metadata
data.collection <- getDataCollection()
data.0 <- getData(data.collection,params$data.collection[1])
meta <- data.0[[1]] #metadata
data.0 <- tail(data.0[[2]],13) #data

#first table:

#select series
series <- c(1, #variable
            2, #M1
            3, #M2-M1
            4, #M2
            5, #M3-M2
            6, #M3
            7) #M3 (moyenne mobile centrée sur 3 mois)

data <- t(data.0[,series])

#set metadata:

met <- as.character(meta[2,series])
met <- as.character(lapply(met,function(x){
  regmatches(
    x,
    regexpr(pattern="M[1-3](-M[1,2])?",text=x,ignore.case=F,perl=T))
}))

met[7] <- ifelse(params$lang=="FR","M3 (moyenne mobile centrée sur 3 mois)","M3 (3-month centred moving average)")

#generate datatable:

#header:

cols <- zoo::as.yearmon(as.character(data[1,]),"%Y-%m")

sketch = htmltools::withTags(table(
  thead(
    tr(
      th(colspan=1,rowspan=2),
      getTH(base::table(as.character(format(cols,"%Y"))),"Y")
    ),
    tr(
      getTH(as.character(format(cols,"%b")),"M")
    )
  )
))

#end header

#data
data <- as.data.frame(data,stringsAsFactors=F)[-1,]
t1 <- genDataTable(data,met[-1],sketch,width=list(width='150px',targets=0))

#ouput the first table (including legend)
setLegend(c("taux de croissance annuel en pourcentage","annual growth rate"),suptext="(a)")
t1
htmltools::div(class="verticalbigspace")
#second table:

#select series
series <- c(1, #variable
            8, #M1
            9, #M2-M1
            10, #M2
            11, #M3-M2
            12) #M3

data <- t(data.0[,series])

#set metadata:
met <- met[-7]

#generate datatable:

#header:
#(same as first table)

#data
data <- as.data.frame(data,stringsAsFactors=F)[-1,]
t2 <- genDataTable(data,met[-1],sketch,width=list(width='150px',targets=0))

#ouput the second table (including legend)
setLegend(c("taux de croissance mensuel en pourcentage","monthly growth rate"),suptext="(a)")
t2
#generate footer:

footer <- htmltools::withTags(
  list(tags$ol(class="laparent",style="font-style: italic; padding-left: 3px;",
            tags$li(HTML(ifelse(params$lang=="FR",
                                "Calculé à partir des flux mensuels corrigés des variations ne résultant pas de transactions effectives (reclassements, changements de périmètre du
secteur des IFM, passages en pertes, fluctuations de taux de change et autres effets de valorisation)",
                                "Growth rates have been calculated on flow data, adjusted for reclassifications, changes in the scope of the MFI sector, write-offs, exchange rate
variations, other revaluations and other changes which do not arise from transactions")))
    )
  )
)

footer <- setFooter(footer,source=c("Banque Centrale Européenne","European Central Bank"))

#output footer:
footer


lcamus/pubstat documentation built on May 27, 2019, 1:45 p.m.