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 de monnaie","Monetary aggregates"), legend=c("données cvs, glissement annuel en pourcentage","seasonally adjusted data, 12-month % change"))
#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 #select series series <- c(1, #variable 2, #Euro area / M1 3, #Euro area / M3 5, #UK / Currency in circulation 6, #UK / M4 7, #US/ M1 8, #US / M2 9, #Japan / M1 10) #Japan / M3 data <- t(data.0[,series]) #set metadata: met <- as.character(meta[2,series]) if (params$lang=="EN") met <- sub("(?<=^GB )billets.*$","Currency in circulation",met,perl=T,ignore.case=T) #countries met.countries <- as.character(lapply(met,function(x){ regmatches( x, regexpr(pattern="^[A-Z]{2}|.+(?=:)",text=x,ignore.case=F,perl=T)) })) met.countries <- unique(met.countries[-1]) met.countries <- c(countrynameFR2EN(met.countries[1]),getCountryByCode(met.countries[-1])) #series met <- as.character(lapply(met,function(x){ regmatches( x, regexpr(pattern="(M\\d)|((billet|currency).*$)",text=x,ignore.case=T)) })) met <- paste0(toupper(substr(met, 1, 1)), substr(met, 2, nchar(met))) met <- paste0(" ",met) #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) spacer <- c(rep("",ncol(data))) data.tmp <- lapply( sapply(seq(2,nrow(data)-1,2),function(x){list(spacer,data[x:(x+1),])}), function(x) x) data.tmp <- append(data.tmp,list(data[1,]),0) data <- data.frame() for (i in 1:length(data.tmp)) data <- rbind(data,data.tmp[[i]]) met <- met[-1] met.tmp <- c() for (i in 1:4) met.tmp <- c(met.tmp,met.countries[i],met[(2*i-1):(2*i)]) met <- met.tmp c.ea <- getCountryByCode("ea",params$lang) met <- sub(c.ea,paste0(c.ea," <sup><i>(a)</i></sup>"),met,ignore.case=T) rm(c.ea) t1 <- genDataTable(data[-1,],met,sketch, # countries.highlight=c("EA","GB","US","JP"),nbdigits=1,subrow=T) countries.highlight=c("EA","GB","US","JP"), countries.highlight.name=met[c(1,4,7,10)],nbdigits=1,subrow=T) #ouput the table t1
#generate footer: footer <- htmltools::withTags( list(tags$ol(class="laparent",style="font-style: italic; padding-left: 3px;", tags$li(HTML(ifelse(params$lang=="FR", "Taux de croissance annuel calculé à partir des flux mensuels corrigés des effets saisonniers et de calendrier et des variations ne résultant pas de transactions effectives (reclassements, changements de périmètre du secteur des IFM (institutions financières monétaires), passages en pertes, fluctuations de taux de change et autres effets de valorisation).", "Growth rates have been calculated from monthly differences in levels adjusted for seasonal and working-day variations and changes which do not arise from transactions (reclassifications, changes in the scope of the MFI sector, write-offs, exchange rate variations and other valuation effects)"))) ) ) ) footer <- setFooter(footer,source=c("Banques centrales nationales, Banque centrale européenne, Thomson-Reuters (Datastream)","National central banks, European Central Bank, Thomson-Reuters (Datastream)")) #output footer: footer
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.