Reader Information
This dashboard provides information on the three main measures of the size of the Northern Ireland food and drinks processing sector; gross turnover, value added and total direct full time equivalent employment. For further information see https://www.daera-ni.gov.uk/publications/size-and-performance-ni-food-and-drinks-processing-sector
Contact Details
DAERA Statistics & Analytical Services Branch welcomes any feedback you may have on this dashboard.
Please e-mail comments to philip.hamilton@daera-ni.gov.uk
Further information can be found on the DAERA Statistics website https://www.daera-ni.gov.uk/landing-pages/statistics
```
---
title: "Northern Ireland Food and Drink Processing Sector Statistics 1989 - 2021"
output:
flexdashboard::flex_dashboard:
orientation: rows
theme: cerulean
source_code: embed
navbar:
- { title: "Cookies", href: "https://www.nisra.gov.uk/cookies", align: right }
---
```{r setup, message=F}
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
#LOAD PACKAGES
library(flexdashboard)
library(knitr)
library(crosstalk)
library(DT)
library(tidyverse)
library(plotly)
library(stringr)
library(reshape2)
library(ggplot2)
# READ IN THE DATA and drop the columns of the dataframe
lsHist <- read.csv("Data.csv", stringsAsFactors = F) %>%
select (-c(X))
# TIDY THE DATA UP
lsHist$Sector[lsHist$Sector == "Milk & Milk Products"] <- "Milk and Milk Products"
lsHist$Sector[lsHist$Sector == "Beef & Sheepmeat"] <- "Beef and Sheepmeat"
lsHist$Sector[lsHist$Sector == "Fruit & Vegetables"] <- "Fruit and Vegetables"
# format variables
lsHist$Sector <- as.factor(lsHist$Sector)
lsHist$Gross.Turnover <- as.numeric(lsHist$Gross.Turnover)
lsHist$Employment <- as.numeric(lsHist$Employment)
lsHist$Value.Added <- as.numeric(lsHist$Value.Added)
# CREATE FINAL DATAFRAME
dat <-
lsHist %>%
arrange(desc(Year))
# CREATE A COPY OF dat FOR GRAPHING THAT DOESN'T USE big.mark ","
dat_graph <- dat
dat$Gross.Turnover <- format(dat$Gross.Turnover, big.mark = ",")
dat$Employment <- format(dat$Employment, big.mark = ",")
dat$Year <- as.Date(ISOdate(dat$Year, 7, 1))
# CROSSTALK
shared_dat <- SharedData$new(dat)
sd_df <- SharedData$new(dat, group = shared_dat$groupName())
# CREATE DATAFRAMES TO USE WITH PLOTLY
tidy_dat <-
dat_graph
# MAKE SOME OBJECTS FOR VALUEBOXES
this.year <- max(as.numeric(tidy_dat$Year))
last.year <- this.year - 1
# CREATE DATAFRAMES FOR CHARTS
Total <-
tidy_dat %>%
filter(Sector == "Total") %>%
select(Year, Sector, Gross.Turnover) %>%
spread(Sector, Gross.Turnover)
Total18 <-
tidy_dat %>%
filter(Year == "2021") %>%
filter(Sector != "Total") %>%
select(Sector, Gross.Turnover)
TotalEm <-
tidy_dat %>%
filter(Sector == "Total") %>%
select(Year, Sector, Employment) %>%
spread(Sector, Employment)
Total18Em <-
tidy_dat %>%
filter(Year == "2021") %>%
filter(Sector != "Total") %>%
select(Sector, Employment)
TotalVA <-
tidy_dat %>%
filter(Sector == "Total") %>%
select(Year, Sector, Value.Added) %>%
spread(Sector, Value.Added)
Total18VA <-
tidy_dat %>%
filter(Year == "2021") %>%
filter(Sector != "Total") %>%
select(Sector, Value.Added)
NI.Totals <-
tidy_dat %>%
select(Year, Sector, Gross.Turnover) %>%
spread(Sector, Gross.Turnover)
NI.TotalsEm <-
tidy_dat %>%
select(Year, Sector, Employment) %>%
spread(Sector, Employment)
NI.TotalsVA <-
tidy_dat %>%
select(Year, Sector, Value.Added) %>%
spread(Sector, Value.Added)
```
Table {data-icon="fa-table"}
===========================================================
Inputs {.sidebar}
-------------------------------------
```{r filter options}
filter_slider("Year", "Year:", sd_df, ~Year, timeFormat = "%Y", step = 365.25)
filter_select("Sector", "Sector:", sd_df, ~Sector)
```
***
**Data can be downloaded using the button above the table**
**PDF option should be used for small reports only**
Row {data-height=750}
-------------------------------------------
###
```{r datatable}
datatable(shared_dat,
colnames = c("Sector", "Year", "Value Added (£ million)", "Employment (FTEs)", "Gross Turnover (£ million)"),
extensions = c('Scroller','Buttons'),
plugins = 'natural',
rownames = F,
options = list(scrollY = 300,
scroller = T,
dom = 'Bfrtip',
buttons = list("colvis", "copy", "print",
list(extend = 'collection',
buttons = list(list(extend = 'csv',
filename = "HistoricalFoodReport"),
list(extend = 'excel',
filename = "HistoricalFoodReport"),
list(extend = 'pdf',
filename = "HistoricalFoodReport")),
text = "Download"
)),
columnDefs = list(list(className = 'dt-center', type = 'natural',
orderData = 0, targets = 1),
list(visible = TRUE, targets = 0))),
fillContainer = T,
class = 'cell-border stripe') %>%
formatStyle(2:5, 'text-align' = 'right')%>%
formatDate(2, method = "getFullYear")
```
Row {data-height=250}
-----------------------------
### Value Box 1
```{r value box 1}
Total.this.year <- Total$Total[Total$Year == this.year]
Total.last.year <- Total$Total[Total$Year == last.year]
pc.diff <- round((Total.this.year - Total.last.year) / Total.last.year * 100, 0)
box.col <- ifelse(pc.diff < 0, "#ff9999", "#96f297")
filler <- ifelse(pc.diff < 0, "decrease", "increase")
icon <- ifelse(pc.diff < 0, "glyphicon-arrow-down", ifelse(pc.diff > 0, "glyphicon-arrow-up", "glyphicon-pause"))
to.print <- ifelse(pc.diff == 0,
paste("No change in Gross Turnover (£ millions) from", last.year, "to", this.year),
paste(abs(pc.diff), "% ", filler, " in Gross Turnover (£ millions) in ", this.year, " from ", last.year, sep = ""))
valueBox(format(Total.this.year, big.mark = ","),
caption = to.print,
icon = icon,
color = box.col)
```
### Value Box 2
```{r value box 2}
highest_GT <-
Total18 %>%
top_n(1, Gross.Turnover) %>%
pull()
highest_Sector <-
Total18 %>%
top_n(1, Gross.Turnover) %>%
pull(Sector)
highest_Sector <- paste(highest_Sector, "had the highest Gross Turnover (£ millions) of all sub-sectors in 2021")
valueBox(format
(highest_GT, big.mark = ","),
caption = highest_Sector,
icon = "fas fa-pound-sign",
color = "#96f297")
```
### Value Box 3
```{r value box 3}
Emp.this.year <- TotalEm$Total[TotalEm$Year == this.year]
Emp.last.year <- TotalEm$Total[TotalEm$Year == last.year]
pc.diff <- round((Emp.this.year - Emp.last.year) / Emp.last.year * 100, 0)
box.col <- ifelse(pc.diff < 0, "#ff9999", "#96f297")
filler <- ifelse(pc.diff < 0, "decrease", "increase")
icon <- ifelse(pc.diff < 0, "glyphicon-arrow-down", ifelse(pc.diff > 0, "glyphicon-arrow-up", "glyphicon-equals"))
to.print <- ifelse(pc.diff == 0,
paste("No change in number of employees (FTEs) from", last.year, "to", this.year),
paste(abs(pc.diff), "% ", filler, " in number of employees (FTEs) in ", this.year, " from ", last.year, sep = ""))
valueBox(format(Emp.this.year, big.mark = ","),
caption = to.print,
icon = icon,
color = box.col)
```
### Value Box 4
```{r value box 4}
highest_Em <-
Total18Em %>%
top_n(1, Employment) %>%
pull()
highest_Sector <-
Total18Em %>%
top_n(1, Employment) %>%
pull(Sector)
highest_Sector <- paste(highest_Sector, "had the highest number of employees (FTEs) of all sub-sectors in 2021")
valueBox(format(highest_Em, big.mark = ","),
caption = highest_Sector,
icon = "fas fa-users",
color = "#96f297")
```
### Value Box 5
```{r value box 5}
VA.this.year <- TotalVA$Total[TotalVA$Year == this.year]
VA.last.year <- TotalVA$Total[TotalVA$Year == last.year]
pc.diff <- round((VA.this.year - VA.last.year) / VA.last.year * 100, 0)
box.col <- ifelse(pc.diff < 0, "#ff9999", "#96f297")
filler <- ifelse(pc.diff < 0, "decrease", "increase")
icon <- ifelse(pc.diff < 0, "glyphicon-arrow-down", ifelse(pc.diff > 0, "glyphicon-arrow-up", "glyphicon-equals"))
to.print <- ifelse(pc.diff == 0,
paste("No change in Value Added (£ millions) from", last.year, "to", this.year),
paste(abs(pc.diff), "% ", filler, " in Value Added (£ millions) in ", this.year, " from ", last.year, sep = ""))
valueBox(format(VA.this.year, big.mark = ","),
caption = to.print,
icon = icon,
color = box.col)
```
### Value Box 6
```{r value box 6}
highest_VA <-
Total18VA %>%
top_n(1, Value.Added) %>%
pull()
highest_Sector <-
Total18VA %>%
top_n(1, Value.Added) %>%
pull(Sector)
highest_Sector <- paste(highest_Sector, "had the highest Value Added (£ millions) of all sub-sectors in 2021")
valueBox(format(highest_VA, big.mark = ","),
caption = highest_Sector,
icon = "fas fa-pound-sign",
color = "#96f297")
```
```{r logo, out.width = "175px", echo=FALSE, fig.align='centre'}
```
Charts {data-icon="fa-chart-line"}
===========================================================
Row {.tabset .tabset-fade}
-------------------------------------
### **Gross Turnover in Northern Ireland Food and Drinks Processing Sector**
```{r NI Totals}
mycolors = c('#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#e377c2')
plot_ly(NI.Totals, x = ~Year, y = ~NI.Totals$`Animal By-Products`, name = 'Animal By-Products', type = 'scatter', mode = 'lines',
visible = T, showlegend = TRUE, line = list(width = 2.5)) %>%
add_trace(y = ~NI.Totals$Bakeries, name = 'Bakeries', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.Totals$`Beef and Sheepmeat`, name = 'Beef and Sheepmeat', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.Totals$Drinks, name = 'Drinks', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.Totals$Eggs, name = 'Eggs', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.Totals$Fish, name = 'Fish', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.Totals$`Fruit and Vegetables`, name = 'Fruit and Vegetables', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.Totals$`Milk and Milk Products`, name = 'Milk and Milk Products', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.Totals$Pigmeat, name = 'Pigmeat', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.Totals$Poultrymeat, name = 'Poultrymeat', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.Totals$Total, name = 'Total', mode = 'lines', visible = 'legendonly') %>%
layout(title = "",
paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)',
xaxis = list(title = "",
gridcolor = 'rgb(255,255,255)',
showgrid = TRUE,
showline = TRUE,
dtick = 1,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = TRUE),
yaxis = list(title = "Gross Turnover (£ million)",
titlefont = list(size = 11),
gridcolor = 'rgb(229,229,299)',
range = c(0),
showgrid = TRUE,
showline = TRUE,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
tickformat = ",",
zeroline = TRUE))
```
### **Employment in Northern Ireland Food and Drinks Processing Sector**
```{r Employment by Sector}
plot_ly(NI.TotalsEm, x = ~Year, y = NI.TotalsEm$`Animal By-Products`, name = 'Animal By-Products', type = 'scatter', mode = 'lines',
visible = T, showlegend = TRUE, line = list(width = 2.5)) %>%
add_trace(y = ~NI.TotalsEm$Bakeries, name = 'Bakeries', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsEm$`Beef and Sheepmeat`, name = 'Beef and Sheepmeat', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsEm$Drinks, name = 'Drinks', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsEm$Eggs, name = 'Eggs', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsEm$Fish, name = 'Fish', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsEm$`Fruit and Vegetables`, name = 'Fruit and Vegetables', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsEm$`Milk and Milk Products`, name = 'Milk and Milk Products', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsEm$Pigmeat, name = 'Pigmeat', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsEm$Poultrymeat, name = 'Poultrymeat', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsEm$Total, name = 'Total', mode = 'lines', visible = 'legendonly') %>%
layout(title = "",
paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)',
xaxis = list(title = "",
gridcolor = 'rgb(255,255,255)',
showgrid = TRUE,
showline = TRUE,
dtick = 1,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = TRUE),
yaxis = list(title = "Employment (FTEs)",
titlefont = list(size = 11),
gridcolor = 'rgb(229,229,299)',
range = c(0),
showgrid = TRUE,
showline = TRUE,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
tickformat = ",",
zeroline = TRUE))
```
### **Value Added in Northern Ireland Food and Drinks Processing Sector**
```{r VA by sector}
plot_ly(NI.TotalsEm, x = ~Year, y = NI.TotalsEm$`Animal By-Products`, name = 'Animal By-Products', type = 'scatter', mode = 'lines',
visible = T, showlegend = TRUE, line = list(width = 2.5)) %>%
add_trace(y = ~NI.TotalsVA$Bakeries, name = 'Bakeries', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsVA$`Beef and Sheepmeat`, name = 'Beef and Sheepmeat', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsVA$Drinks, name = 'Drinks', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsVA$Eggs, name = 'Eggs', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsVA$Fish, name = 'Fish', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsVA$`Fruit and Vegetables`, name = 'Fruit and Vegetables', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsVA$`Milk and Milk Products`, name = 'Milk and Milk Products', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsVA$Pigmeat, name = 'Pigmeat', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsVA$Poultrymeat, name = 'Poultrymeat', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.TotalsVA$Total, name = 'Total', mode = 'lines', visible = 'legendonly') %>%
layout(title = "",
paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)',
xaxis = list(title = "",
gridcolor = 'rgb(255,255,255)',
showgrid = TRUE,
showline = TRUE,
dtick = 1,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = TRUE),
yaxis = list(title = "Value Added (£ million)",
titlefont = list(size = 11),
gridcolor = 'rgb(229,229,299)',
range = c(0),
showgrid = TRUE,
showline = TRUE,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
tickformat = ",",
zeroline = TRUE))
```
```{r time trend, out.width = "175px", echo=FALSE, fig.align='centre'}
```
Time Trend {data-icon="fa-chart-line"}
===========================================================
### **Press PLAY to see how Gross Turnover, Employment and Value Added generated by each Sector has changed over time**
```{r Trend over time}
# READ IN THE DATA and drop the columns of the dataframe
Food <- lsHist %>%
filter(Sector != "Total")
mycolors = c('#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#e377c2')
# Create the animation
gg <- ggplot(Food, aes(Gross.Turnover, Employment, color = Sector)) +
geom_point(aes(size = Value.Added, frame = Year)) +
labs(x='Gross Turnover (£ million)', y='Employment (FTEs)') +
annotate("text", x=150, y=6600, label="The size of each bubble represent the Value Added generated in £ millions") +
scale_size_continuous(range = c(2, 35)) +
theme(panel.background = element_rect(fill = 'white', colour = 'white')) +
theme(legend.title=element_blank())+
scale_x_log10()
ggplotly(gg)
```
Reader Information {data-icon="fa-chart-line"}
===========================================================
**Reader Information**
*This dashboard provides information on the three main measures of the size of the Northern Ireland food and drinks processing sector; gross turnover, value added and total direct full time equivalent employment. For further information see https://www.daera-ni.gov.uk/publications/size-and-performance-ni-food-and-drinks-processing-sector*
**Contact Details**
*DAERA Statistics & Analytical Services Branch welcomes any feedback you may have on this dashboard.*
*Please e-mail comments to philip.hamilton@daera-ni.gov.uk*
*Further information can be found on the DAERA Statistics website https://www.daera-ni.gov.uk/landing-pages/statistics*
Row {.tabset .tabset-fade}
-------------------------------------
```