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é : Croissance du produit intérieur brut","Activity: GDP growth"), legend=c("PIB aux prix de l'année précédente chaînés en données cvs-cjo, en pourcentage","GDP at chain-linked, previous-year prices, seasonally and working day adjusted"))
#get data & metadata data.collection <- getDataCollection(params$data.directory) data.y.0 <- getData(data.collection,params$data.collection[1])[[2]] data.q.0 <- tail(getData(data.collection,params$data.collection[2])[[2]],5) meta <- getData(data.collection,params$data.collection[1])[[1]] #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.q <- t(data.q.0[,series]) #set metadata: met <- as.character(meta[2,series]) met <- trimws(unlist(lapply(strsplit(met,":"),"[[",1))) met <- countrynameFR2EN(met) setSup <- function(country,sup,met) { c <- getCountryByCode(country,params$lang) res <- sub(c,paste0(c," <sup><i>(",sup,")</i></sup>"),met,ignore.case=T) return(res) } map <- list(c("ie","a"),c("sk","a"),c("ro","a"),c("us","a"),c("jp","b")) for (co in map) met <- setSup(co[1],co[2],met) #generate datatable: #header: col.q <- as.yearqtr(as.character(data.q[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","Annual average")), th(colspan=13,rowspan=1,ifelse(params$lang=="FR","Variation trimestrielle","Quarterly change"), style=sep.style) ), tr( lapply(as.character(data.y[1,]), th, rowspan=2), getTH(base::table(as.character(format(col.q,"%Y"))),"Y",sep.style) ), tr( getTH(as.character(format(col.q,ifelse(params$lang=="FR","T%q","Q%q"))),"Q",sep.style) ) ) )) #end header #data countries.lib <- function(co) { met[sapply(co,function(x){grep(paste0("^",getCountryByCode(x)),met)})] } data <- as.data.frame(cbind(data.y,data.q), stringsAsFactors=F)[-1,] t1 <- genDataTable(data,met[-1],sketch, countries.highlight.name=countries.lib(c("FR","EA","EU","US","JP")), countries.highlight=c("FR","EA","EU","US","JP"), sep.col=5,sep.style=sep.style) #ouput the table t1
footer <- htmltools::withTags( list( p(style="text-align: left; font-style: italic; line-height: 50%;", ifelse(params$lang=="FR", "Basé sur la méthodologie SEC 2010 sauf États-Unis et Japon", "All growth rates based on ESA 2010 methodology except for United States and Japan")), tags$ol(class="laparent",style="font-style: italic; padding-left: 3px;", tags$li(HTML(ifelse(params$lang=="FR", "PIB aux prix de l'année précédente chaînés en données cvs", "GDP at chain-linked, previous prices, seasonally adjusted"))), tags$li(HTML(ifelse(params$lang=="FR", "PIB en données cvs base 2000", "Seasonally adjusted, base year 2000"))) ) ) ) footer <- setFooter(footer,source=c("Eurostat, données nationales","Eurostat, National data")) #output footer: footer
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.