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("Activité : production industrielle hors bâtiment","Activity: industrial production excluding construction"), legend=c("variation en pourcentage","percentage change"))
#get data & metadata data.collection <- getDataCollection(params$data.directory) data.y.0 <- getData(data.collection,params$data.collection[1]) #annual average meta <- data.y.0[[1]] #metadata data.y.0 <- data.y.0[[2]] data.m.yoy.0 <- tail(getData(data.collection,params$data.collection[2])[[2]][,1:33],6) #monthly change data.m.mc.0 <- tail(getData(data.collection,params$data.collection[2])[[2]][,c(1,34:65)],6) #year-on-year change #select series series <- c(1, #variable 2, #France 3, #Germany 4, #Austria 5, #Belgium 6, #Cyprus 7, #Spain 8, #Estonia 9, #Finland 10, #Greece 11, #Ireland 12, #Italy 13, #Latvia 14, #Lithuania 15, #Luxembourg, 16, #Malta 17, #Netherlands 18, #Portugal 19, #Slovakia 20, #Slovenia 21, #Euro area 22, #Bulgaria 23, #Croatia 24, #Denmark 25, #Hungary 26, #Poland 27, #Romania 28, #United Kingdom 29, #Sweden 30, #Czech Republic 31, #European union 32, #United States 33) #Japan if (all(is.na(tail(data.y.0[,tail(series,length(series)-1)],1)))) { #if last obs is NA then shift one previous end <- nrow(data.y.0)-1 begin <- end-3 data.y <- t(data.y.0[begin:end,series]) rm(begin,end) } else data.y <- t(tail(data.y.0[,series],3)) data.m.mc <- t(data.m.mc.0[,series]) data.m.yoy <- t(data.m.yoy.0[,series]) #set metadata: met <- as.character(meta[2,series]) # met <- trimws(unlist(lapply(strsplit(met,":"),"[[",1))) met <- sub(" \\w+$","",met,perl=T) met <- countrynameFR2EN(met) c.eu.us.jp <- getCountryByCode(c("eu","us","jp"),params$lang) c.li <- c("a","b","b") for (x in seq_along(c.li)) met <- sub(c.eu.us.jp[x],paste0(c.eu.us.jp[x]," <sup><i>(",c.li[x],")</i></sup>"),met,ignore.case=T) # met <- sub(c.eu,paste0(c.eu," <sup><i>(a)</i></sup>"),met,ignore.case=T) rm(c.eu.us.jp,c.li) #generate datatable: #header: col.m.mc <- zoo::as.yearmon(as.character(data.m.mc[1,]),"%Y-%m") col.m.yoy <- zoo::as.yearmon(as.character(data.m.yoy[1,]),"%Y-%m") sketch = htmltools::withTags(table( thead( tr( th(colspan=1,rowspan=3), th(colspan=3,rowspan=1,ifelse(params$lang=="FR","Moyenne annuelle (cjo)","Annual average (wda)")), th(colspan=6,rowspan=1,ifelse(params$lang=="FR","Variation mensuelle (cvs-cjo)","Monthly variation (sa-wda)"), style=sep.style), th(colspan=6,rowspan=1,ifelse(params$lang=="FR","Glissement annuel (cjo)","Year-on-year (wda)"), style=sep.style) ), tr( lapply(as.character(data.y[1,]), th, rowspan=2), getTH(base::table(as.character(format(col.m.mc,"%Y"))),"Y",sep.style), getTH(base::table(as.character(format(col.m.yoy,"%Y"))),"Y",sep.style) ), tr( getTH(as.character(format(col.m.mc,"%b")),"M",sep.style), getTH(as.character(format(col.m.yoy,"%b")),"M",sep.style) ) ) )) #end header #data data <- as.data.frame(cbind(data.y,data.m.mc,data.m.yoy), stringsAsFactors=F) t1 <- genDataTable(data[-1,],met[-1],sketch, countries.highlight=c("FR","EA","EU","US","JP"), countries.highlight.name=met[c(2,21,31:33)], sep.col=c(5,11),sep.style=sep.style) #ouput the table t1
#generate footer: footer <- htmltools::withTags( list( p(style="text-align: left; font-style: italic; line-height: 50%;", ifelse(params$lang=="FR", "Indices harmonisés sauf pour les États-Unis et le Japon", "Harmonised indices except for the United States and Japan")), tags$ol(class="laparent",style="font-style: italic; padding-left: 3px;", tags$li(HTML(ifelse(params$lang=="FR", "Pour les pays européens, la zone euro et l'Union européenne, NACE Rev2. Source Eurostat", "For European Countries, Euro area and European Union, NACE Rev2. Source: Eurostat."))), tags$li(HTML(ifelse(params$lang=="FR", "Pour les États-Unis et le Japon, données cvs", "Seasonally adjusted data"))) ) ) ) footer <- setFooter(footer,source=c("nationales, BCE","national data, ECB")) #output footer: footer
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.