---
title: "Northern Ireland livestock 1923 - 2018"
output:
flexdashboard::flex_dashboard:
orientation: rows
theme: cerulean
source_code: embed
logo: "daera_logo300dpi.png"
navbar:
- { title: "See more DAERA statistics", href: "https://www.daera-ni.gov.uk/topics/statistics", 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)
# READ IN THE DATA
lsHist <- read.csv("Livestock by County, June 1921 - 2018_online.csv", header = F, stringsAsFactors = F)
# TIDY THE DATA UP
lsHist[lsHist == "Horses & Ponies"] <- "Horses and Ponies"
lsHist[lsHist == "Mules, Jennets & Asses"] <- "Mules, Jennets and Asses"
col.names <- c("Year", tail(paste(t(lsHist[1,]),t(lsHist[2,]),sep="/"),n=-1))
lsHist <- lsHist[-(1:2), ]
lsHist <- setNames(lsHist, col.names)
lsHist <- melt(lsHist, id=c("Year"))
lsHist <- separate(data = lsHist, col = variable, into = c("Animal", "County"), sep = "/")
lsHist$County <- str_to_sentence(lsHist$County)
lsHist$County[lsHist$County == "Total n. Ireland"] <- "NI"
# format variables
lsHist$Animal <- str_trim(lsHist$Animal)
lsHist$Animal <- factor(lsHist$Animal)
lsHist$value <- as.numeric(lsHist$value)
lsHist$County <- factor(lsHist$County, levels = c("NI", "Antrim", "Armagh", "Down",
"Fermanagh", "Londonderry", "Tyrone"), ordered = T)
# 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$value <- format(dat$value, big.mark = ",")
dat$Year <- as.Date(ISOdate(dat$Year, 6, 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
cattle <-
tidy_dat %>%
filter(Animal == "Cattle") %>%
select(Year, County, value) %>%
spread(County, value)
cows <-
tidy_dat %>%
filter(Animal == "Cows") %>%
select(Year, County, value) %>%
spread(County, value)
sheep <-
tidy_dat %>%
filter(Animal == "Sheep") %>%
select(Year, County, value) %>%
spread(County, value)
pigs <-
tidy_dat %>%
filter(Animal == "Pigs") %>%
select(Year, County, value) %>%
spread(County, value)
poultry <-
tidy_dat %>%
filter(Animal == "Poultry") %>%
select(Year, County, value) %>%
spread(County, value)
horses <-
tidy_dat %>%
filter(Animal == "Horses and Ponies") %>%
select(Year, County, value) %>%
spread(County, value)
ewes <-
tidy_dat %>%
filter(Animal == "Ewes") %>%
select(Year, County, value) %>%
spread(County, value)
NI.Totals <-
tidy_dat %>%
filter(County == "NI") %>%
select(Year, Animal, value) %>%
spread(Animal, value)
antrim <-
tidy_dat %>%
filter(County == "Antrim") %>%
select(Year, Animal, value) %>%
spread(Animal, value)
armagh <-
tidy_dat %>%
filter(County == "Armagh") %>%
select(Year, Animal, value) %>%
spread(Animal, value)
down <-
tidy_dat %>%
filter(County == "Down") %>%
select(Year, Animal, value) %>%
spread(Animal, value)
fermanagh <-
tidy_dat %>%
filter(County == "Fermanagh") %>%
select(Year, Animal, value) %>%
spread(Animal, value)
londonderry <-
tidy_dat %>%
filter(County == "Londonderry") %>%
select(Year, Animal, value) %>%
spread(Animal, value)
tyrone <-
tidy_dat %>%
filter(County == "Tyrone") %>%
select(Year, Animal, value) %>%
spread(Animal, value)
```
Table {data-icon="fa-table"}
===========================================================
Inputs {.sidebar}
-------------------------------------
```{r filter options}
filter_slider("Year", "Year:", sd_df, ~Year, timeFormat = "%Y", step = 365.25)
filter_select("Animal", "Animal:", sd_df, ~Animal)
filter_select("County", "County", sd_df, ~County)
```
***
**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(sd_df,
colnames = c("Year", "Animal", "County", "Head"),
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 = "HistoricalLivestock"),
list(extend = 'excel',
filename = "HistoricalLivestock"),
list(extend = 'pdf',
filename = "HistoricalLivestock")),
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(1:4, 'text-align' = 'left') %>%
formatDate(1, method = "getFullYear")
```
Row {data-height=250}
-----------------------------
### Value Box 1
```{r value box 1}
cattle.this.year <- cattle$NI[cattle$Year == this.year]
cattle.last.year <- cattle$NI[cattle$Year == last.year]
pc.diff <- round((cattle.this.year - cattle.last.year) / cattle.last.year * 100, 0)
box.col <- ifelse(pc.diff < 0, "#ff9999", "#96f297")
filler <- ifelse(pc.diff < 0, "fewer", "more")
icon <- ifelse(pc.diff < 0, "glyphicon-arrow-down", ifelse(pc.diff > 0, "glyphicon-arrow-up", "glyphicon-minus"))
to.print <- ifelse(pc.diff == 0,
paste("No change in cattle from", last.year, "to", this.year),
paste(abs(pc.diff), "% ", filler, " cattle in ", this.year, " than in ", last.year, sep = ""))
valueBox(format(cattle.this.year, big.mark = ","),
caption = to.print,
icon = icon,
color = box.col,
href = "#charts")
```
### Value Box 2
```{r value box 2}
cows.this.year <- cows$NI[cows$Year == this.year]
cows.last.year <- cows$NI[cows$Year == last.year]
pc.diff <- round((cows.this.year - cows.last.year) / cows.last.year * 100, 0)
box.col <- ifelse(pc.diff < 0, "#ff9999", "#96f297")
filler <- ifelse(pc.diff < 0, "fewer", "more")
icon <- ifelse(pc.diff < 0, "glyphicon-arrow-down", ifelse(pc.diff > 0, "glyphicon-arrow-up", "glyphicon-minus"))
to.print <- ifelse(pc.diff == 0,
paste("No change in cows from", last.year, "to", this.year),
paste(abs(pc.diff), "% ", filler, " cows in ", this.year, " than in ", last.year, sep = ""))
valueBox(format(cows.this.year, big.mark = ","),
caption = to.print,
icon = icon,
color = box.col,
href = "#charts")
```
### Value Box 3
```{r value box 3}
sheep.this.year <- sheep$NI[sheep$Year == this.year]
sheep.last.year <- sheep$NI[sheep$Year == last.year]
pc.diff <- round((sheep.this.year - sheep.last.year) / sheep.last.year * 100, 0)
box.col <- ifelse(pc.diff < 0, "#ff9999", "#96f297")
filler <- ifelse(pc.diff < 0, "fewer", "more")
icon <- ifelse(pc.diff < 0, "glyphicon-arrow-down", ifelse(pc.diff > 0, "glyphicon-arrow-up", "glyphicon-minus"))
to.print <- ifelse(pc.diff == 0,
paste("No change in sheep from", last.year, "to", this.year),
paste(abs(pc.diff), "% ", filler, " sheep in ", this.year, " than in ", last.year, sep = ""))
valueBox(format(sheep.this.year, big.mark = ","),
caption = to.print,
icon = icon,
color = box.col,
href = "#charts")
```
### Value Box 4
```{r value box 4}
pigs.this.year <- pigs$NI[pigs$Year == this.year]
pigs.last.year <- pigs$NI[pigs$Year == last.year]
pc.diff <- round((pigs.this.year - pigs.last.year) / pigs.last.year * 100, 0)
box.col <- ifelse(pc.diff < 0, "#ff9999", "#96f297")
filler <- ifelse(pc.diff < 0, "fewer", "more")
icon <- ifelse(pc.diff < 0, "glyphicon-arrow-down", ifelse(pc.diff > 0, "glyphicon-arrow-up", "glyphicon-minus"))
to.print <- ifelse(pc.diff == 0,
paste("No change in pigs from", last.year, "to", this.year),
paste(abs(pc.diff), "% ", filler, " pigs in ", this.year, " than in ", last.year, sep = ""))
valueBox(format(pigs.this.year, big.mark = ","),
caption = to.print,
icon = icon,
color = box.col,
href = "#charts")
```
### Value Box 5
```{r value box 5}
poultry.this.year <- poultry$NI[poultry$Year == this.year]
poultry.last.year <- poultry$NI[poultry$Year == last.year]
pc.diff <- round((poultry.this.year - poultry.last.year) / poultry.last.year * 100, 0)
box.col <- ifelse(pc.diff < 0, "#ff9999", "#96f297")
filler <- ifelse(pc.diff < 0, "fewer", "more")
icon <- ifelse(pc.diff < 0, "glyphicon-arrow-down", ifelse(pc.diff > 0, "glyphicon-arrow-up", "glyphicon-minus"))
to.print <- ifelse(pc.diff == 0,
paste("No change in poultry from", last.year, "to", this.year),
paste(abs(pc.diff), "% ", filler, " poultry in ", this.year, " than in ", last.year, sep = ""))
valueBox(format(poultry.this.year, big.mark = ","),
caption = to.print,
icon = icon,
color = box.col,
href = "#charts")
```
```{r logo, out.width = "175px", echo=FALSE, fig.align='centre'}
```
Charts {data-icon="fa-chart-line"}
===========================================================
Row {.tabset .tabset-fade}
-------------------------------------
### **All livestock in NI**
```{r NI totals}
mycolors = c('#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#e377c2')
plot_ly(NI.Totals, x = ~Year, y = ~Cattle, name = 'Cattle', type = 'scatter', mode = 'lines',
visible = T, showlegend = TRUE, line = list(width = 2.5)) %>%
add_trace(y = ~NI.Totals$Cows, name = 'Cows', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.Totals$Sheep, name = 'Sheep', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.Totals$Ewes, name = 'Ewes', mode = 'lines', visible = T) %>%
add_trace(y = ~NI.Totals$Goats, name = 'Goats', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~NI.Totals$Pigs, name = 'Pigs', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~NI.Totals$`Female Breeding Pigs`, name = 'Female breeding pigs', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~NI.Totals$Poultry, name = 'Poultry', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~NI.Totals$`Horses and Ponies`, name = 'Horses and ponies', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~NI.Totals$`Mules, Jennets and Asses`, name = 'Mules, jennets, asses', 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 = FALSE,
showline = TRUE,
dtick = 5,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = FALSE),
yaxis = list(title = "Head",
titlefont = list(size = 11),
gridcolor = 'rgb(229,229,299)',
showgrid = TRUE,
showline = TRUE,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
tickformat = ",",
zeroline = FALSE))
```
### **Co Antrim**
```{r Antrim}
plot_ly(antrim, x = ~Year, y = ~Cattle, name = 'Cattle', type = 'scatter', mode = 'lines',
visible = T, showlegend = TRUE, line = list(width = 2.5)) %>%
add_trace(y = ~antrim$Cows, name = 'Cows', mode = 'lines', visible = T) %>%
add_trace(y = ~antrim$Sheep, name = 'Sheep', mode = 'lines', visible = T) %>%
add_trace(y = ~antrim$Ewes, name = 'Ewes', mode = 'lines', visible = T) %>%
add_trace(y = ~antrim$Goats, name = 'Goats', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~antrim$Pigs, name = 'Pigs', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~antrim$`Female Breeding Pigs`, name = 'Female breeding pigs', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~antrim$Poultry, name = 'Poultry', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~antrim$`Horses and Ponies`, name = 'Horses and ponies', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~antrim$`Mules, Jennets and Asses`, name = 'Mules, jennets, asses', 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 = FALSE,
showline = TRUE,
dtick = 5,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = FALSE),
yaxis = list(title = "Head",
titlefont = list(size = 11),
gridcolor = 'rgb(229,229,299)',
showgrid = TRUE,
showline = TRUE,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
tickformat = ",",
zeroline = FALSE))
```
### **Co Armagh**
```{r Armagh}
plot_ly(armagh, x = ~Year, y = ~Cattle, name = 'Cattle', type = 'scatter', mode = 'lines',
visible = T, showlegend = TRUE, line = list(width = 2.5)) %>%
add_trace(y = ~armagh$Cows, name = 'Cows', mode = 'lines', visible = T) %>%
add_trace(y = ~armagh$Sheep, name = 'Sheep', mode = 'lines', visible = T) %>%
add_trace(y = ~armagh$Ewes, name = 'Ewes', mode = 'lines', visible = T) %>%
add_trace(y = ~armagh$Goats, name = 'Goats', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~armagh$Pigs, name = 'Pigs', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~armagh$`Female Breeding Pigs`, name = 'Female breeding pigs', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~armagh$Poultry, name = 'Poultry', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~armagh$`Horses and Ponies`, name = 'Horses and ponies', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~armagh$`Mules, Jennets and Asses`, name = 'Mules, jennets, asses', 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 = FALSE,
showline = TRUE,
dtick = 5,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = FALSE),
yaxis = list(title = "Head",
titlefont = list(size = 11),
gridcolor = 'rgb(229,229,299)',
showgrid = TRUE,
showline = TRUE,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
tickformat = ",",
zeroline = FALSE))
```
### **Co Down**
```{r Down}
plot_ly(down, x = ~Year, y = ~Cattle, name = 'Cattle', type = 'scatter', mode = 'lines',
visible = T, showlegend = TRUE, line = list(width = 2.5)) %>%
add_trace(y = ~down$Cows, name = 'Cows', mode = 'lines', visible = T) %>%
add_trace(y = ~down$Sheep, name = 'Sheep', mode = 'lines', visible = T) %>%
add_trace(y = ~down$Ewes, name = 'Ewes', mode = 'lines', visible = T) %>%
add_trace(y = ~down$Goats, name = 'Goats', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~down$Pigs, name = 'Pigs', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~down$`Female Breeding Pigs`, name = 'Female breeding pigs', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~armagh$Poultry, name = 'Poultry', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~down$`Horses and Ponies`, name = 'Horses and ponies', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~down$`Mules, Jennets and Asses`, name = 'Mules, jennets, asses', 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 = FALSE,
showline = TRUE,
dtick = 5,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = FALSE),
yaxis = list(title = "Head",
titlefont = list(size = 11),
gridcolor = 'rgb(229,229,299)',
showgrid = TRUE,
showline = TRUE,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
tickformat = ",",
zeroline = FALSE))
```
### **Co Fermanagh**
```{r Fermanagh}
plot_ly(fermanagh, x = ~Year, y = ~Cattle, name = 'Cattle', type = 'scatter', mode = 'lines',
visible = T, showlegend = TRUE, line = list(width = 2.5)) %>%
add_trace(y = ~fermanagh$Cows, name = 'Cows', mode = 'lines', visible = T) %>%
add_trace(y = ~fermanagh$Sheep, name = 'Sheep', mode = 'lines', visible = T) %>%
add_trace(y = ~fermanagh$Ewes, name = 'Ewes', mode = 'lines', visible = T) %>%
add_trace(y = ~fermanagh$Goats, name = 'Goats', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~fermanagh$Pigs, name = 'Pigs', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~fermanagh$`Female Breeding Pigs`, name = 'Female breeding pigs', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~armagh$Poultry, name = 'Poultry', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~fermanagh$`Horses and Ponies`, name = 'Horses and ponies', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~fermanagh$`Mules, Jennets and Asses`, name = 'Mules, jennets, asses', 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 = FALSE,
showline = TRUE,
dtick = 5,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = FALSE),
yaxis = list(title = "Head",
titlefont = list(size = 11),
gridcolor = 'rgb(229,229,299)',
showgrid = TRUE,
showline = TRUE,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
tickformat = ",",
zeroline = FALSE))
```
### **Co Londonderry**
```{r Londonderry}
plot_ly(londonderry, x = ~Year, y = ~Cattle, name = 'Cattle', type = 'scatter', mode = 'lines',
visible = T, showlegend = TRUE, line = list(width = 2.5)) %>%
add_trace(y = ~londonderry$Cows, name = 'Cows', mode = 'lines', visible = T) %>%
add_trace(y = ~londonderry$Sheep, name = 'Sheep', mode = 'lines', visible = T) %>%
add_trace(y = ~londonderry$Ewes, name = 'Ewes', mode = 'lines', visible = T) %>%
add_trace(y = ~londonderry$Goats, name = 'Goats', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~londonderry$Pigs, name = 'Pigs', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~londonderry$`Female Breeding Pigs`, name = 'Female breeding pigs', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~londonderry$Poultry, name = 'Poultry', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~londonderry$`Horses and Ponies`, name = 'Horses and ponies', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~londonderry$`Mules, Jennets and Asses`, name = 'Mules, jennets, asses', 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 = FALSE,
showline = TRUE,
dtick = 5,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = FALSE),
yaxis = list(title = "Head",
titlefont = list(size = 11),
gridcolor = 'rgb(229,229,299)',
showgrid = TRUE,
showline = TRUE,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
tickformat = ",",
zeroline = FALSE))
```
### **Co Tyrone**
```{r Tyrone}
plot_ly(tyrone, x = ~Year, y = ~Cattle, name = 'Cattle', type = 'scatter', mode = 'lines',
visible = T, showlegend = TRUE, line = list(width = 2.5)) %>%
add_trace(y = ~tyrone$Cows, name = 'Cows', mode = 'lines', visible = T) %>%
add_trace(y = ~tyrone$Sheep, name = 'Sheep', mode = 'lines', visible = T) %>%
add_trace(y = ~tyrone$Ewes, name = 'Ewes', mode = 'lines', visible = T) %>%
add_trace(y = ~tyrone$Goats, name = 'Goats', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~tyrone$Pigs, name = 'Pigs', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~tyrone$`Female Breeding Pigs`, name = 'Female breeding pigs', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~tyrone$Poultry, name = 'Poultry', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~tyrone$`Horses and Ponies`, name = 'Horses and ponies', mode = 'lines', visible = 'legendonly') %>%
add_trace(y = ~tyrone$`Mules, Jennets and Asses`, name = 'Mules, jennets, asses', 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 = FALSE,
showline = TRUE,
dtick = 5,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = FALSE),
yaxis = list(title = "Head",
titlefont = list(size = 11),
gridcolor = 'rgb(229,229,299)',
showgrid = TRUE,
showline = TRUE,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
tickformat = ",",
zeroline = FALSE))
```
Row {.tabset .tabset-fade}
-------------------------------------
### **Cattle by county**
```{r cattle by county}
plot_ly(cattle, x = ~Year, y = ~NI, name = 'NI Total', type = 'scatter', mode = 'lines',
visible = 'legendonly', showlegend = TRUE, line = list(width = 2.5)) %>%
add_trace(y = ~cattle$Antrim, name = 'Antrim', mode = 'lines', visible = T) %>%
add_trace(y = ~cattle$Armagh, name = 'Armagh', mode = 'lines', visible = T) %>%
add_trace(y = ~cattle$Down, name = 'Down', mode = 'lines', visible = T) %>%
add_trace(y = ~cattle$Fermanagh, name = 'Fermanagh', mode = 'lines', visible = T) %>%
add_trace(y = ~cattle$Londonderry, name = 'Londonderry', mode = 'lines', visible = T) %>%
add_trace(y = ~cattle$Tyrone, name = 'Tyrone', mode = 'lines', visible = T) %>%
layout(title = "",
paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",
xaxis = list(title = "",
gridcolor = 'rgb(255,255,255)',
showgrid = FALSE,
showline = TRUE,
dtick = 5,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = FALSE),
yaxis = list(title = "Cattle (head)",
titlefont = list(size = 11),
gridcolor = 'rgb(229,229,299)',
showgrid = TRUE,
showline = TRUE,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
tickformat = ",",
zeroline = FALSE))
```
### **Cows by county**
```{r cows by county}
plot_ly(cows, x = ~Year, y = ~NI, name = 'NI Total', type = 'scatter', mode = 'lines',
visible = 'legendonly', showlegend = TRUE, line = list(width = 2.5)) %>%
add_trace(y = ~cows$Antrim, name = 'Antrim', mode = 'lines', visible = T) %>%
add_trace(y = ~cows$Armagh, name = 'Armagh', mode = 'lines', visible = T) %>%
add_trace(y = ~cows$Down, name = 'Down', mode = 'lines', visible = T) %>%
add_trace(y = ~cows$Fermanagh, name = 'Fermanagh', mode = 'lines', visible = T) %>%
add_trace(y = ~cows$Londonderry, name = 'Londonderry', mode = 'lines', visible = T) %>%
add_trace(y = ~cows$Tyrone, name = 'Tyrone', mode = 'lines', visible = T) %>%
layout(title = "",
paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",
xaxis = list(title = "",
gridcolor = 'rgb(255,255,255)',
showgrid = FALSE,
showline = TRUE,
dtick = 5,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = FALSE),
yaxis = list(title = "Cows (head)",
titlefont = list(size = 11),
gridcolor = 'rgb(229,229,299)',
showgrid = TRUE,
showline = TRUE,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
tickformat = ",",
zeroline = FALSE))
```
### **Sheep by county**
```{r sheep by county}
plot_ly(sheep, x = ~Year, y = ~NI, name = 'NI Total', type = 'scatter', mode = 'lines',
visible = 'legendonly', showlegend = TRUE, line = list(width = 2.5)) %>%
add_trace(y = ~sheep$Antrim, name = 'Antrim', mode = 'lines', visible = T) %>%
add_trace(y = ~sheep$Armagh, name = 'Armagh', mode = 'lines', visible = T) %>%
add_trace(y = ~sheep$Down, name = 'Down', mode = 'lines', visible = T) %>%
add_trace(y = ~sheep$Fermanagh, name = 'Fermanagh', mode = 'lines', visible = T) %>%
add_trace(y = ~sheep$Londonderry, name = 'Londonderry', mode = 'lines', visible = T) %>%
add_trace(y = ~sheep$Tyrone, name = 'Tyrone', mode = 'lines', visible = T) %>%
layout(title = "",
paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",
xaxis = list(title = "",
gridcolor = 'rgb(255,255,255)',
showgrid = FALSE,
showline = TRUE,
dtick = 5,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = FALSE),
yaxis = list(title = "Sheep (head)",
titlefont = list(size = 11),
gridcolor = 'rgb(229,229,299)',
showgrid = TRUE,
showline = TRUE,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
tickformat = ",",
zeroline = FALSE))
```
### **Ewes by county**
```{r Ewes by county}
plot_ly(ewes, x = ~Year, y = ~NI, name = 'NI Total', type = 'scatter', mode = 'lines',
visible = 'legendonly', showlegend = TRUE, line = list(width = 2.5)) %>%
add_trace(y = ~ewes$Antrim, name = 'Antrim', mode = 'lines', visible = T) %>%
add_trace(y = ~ewes$Armagh, name = 'Armagh', mode = 'lines', visible = T) %>%
add_trace(y = ~ewes$Down, name = 'Down', mode = 'lines', visible = T) %>%
add_trace(y = ~ewes$Fermanagh, name = 'Fermanagh', mode = 'lines', visible = T) %>%
add_trace(y = ~ewes$Londonderry, name = 'Londonderry', mode = 'lines', visible = T) %>%
add_trace(y = ~ewes$Tyrone, name = 'Tyrone', mode = 'lines', visible = T) %>%
layout(title = "",
paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",
xaxis = list(title = "",
gridcolor = 'rgb(255,255,255)',
showgrid = FALSE,
showline = TRUE,
dtick = 5,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = FALSE),
yaxis = list(title = "Ewes (head)",
titlefont = list(size = 11),
gridcolor = 'rgb(229,229,299)',
showgrid = TRUE,
showline = TRUE,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
tickformat = ",",
zeroline = FALSE))
```
### **Pigs by county**
```{r pigs by county}
plot_ly(pigs, x = ~Year, y = ~NI, name = 'NI Total', type = 'scatter', mode = 'lines',
visible = 'legendonly', showlegend = TRUE, line = list(width = 2.5)) %>%
add_trace(y = ~pigs$Antrim, name = 'Antrim', mode = 'lines', visible = T) %>%
add_trace(y = ~pigs$Armagh, name = 'Armagh', mode = 'lines', visible = T) %>%
add_trace(y = ~pigs$Down, name = 'Down', mode = 'lines', visible = T) %>%
add_trace(y = ~pigs$Fermanagh, name = 'Fermanagh', mode = 'lines', visible = T) %>%
add_trace(y = ~pigs$Londonderry, name = 'Londonderry', mode = 'lines', visible = T) %>%
add_trace(y = ~pigs$Tyrone, name = 'Tyrone', mode = 'lines', visible = T) %>%
layout(title = "",
paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",
xaxis = list(title = "",
gridcolor = 'rgb(255,255,255)',
showgrid = FALSE,
showline = TRUE,
dtick = 5,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = FALSE),
yaxis = list(title = "Pigs (head)",
titlefont = list(size = 11),
gridcolor = 'rgb(229,229,299)',
showgrid = TRUE,
showline = TRUE,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
tickformat = ",",
zeroline = FALSE))
```
### **Poultry by county**
```{r poultry by county}
plot_ly(poultry, x = ~Year, y = ~NI, name = 'NI Total', type = 'scatter', mode = 'lines',
visible = 'legendonly', showlegend = TRUE, line = list(width = 2.5)) %>%
add_trace(y = ~poultry$Antrim, name = 'Antrim', mode = 'lines', visible = T) %>%
add_trace(y = ~poultry$Armagh, name = 'Armagh', mode = 'lines', visible = T) %>%
add_trace(y = ~poultry$Down, name = 'Down', mode = 'lines', visible = T) %>%
add_trace(y = ~poultry$Fermanagh, name = 'Fermanagh', mode = 'lines', visible = T) %>%
add_trace(y = ~poultry$Londonderry, name = 'Londonderry', mode = 'lines', visible = T) %>%
add_trace(y = ~poultry$Tyrone, name = 'Tyrone', mode = 'lines', visible = T) %>%
layout(title = "",
paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",
xaxis = list(title = "",
gridcolor = 'rgb(255,255,255)',
showgrid = FALSE,
showline = TRUE,
dtick = 5,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
zeroline = FALSE),
yaxis = list(title = "Poultry (head)",
titlefont = list(size = 11),
gridcolor = 'rgb(229,229,299)',
showgrid = TRUE,
showline = TRUE,
showticklabels = TRUE,
tickcolor = 'rgb(127,127,127)',
ticks = 'outside',
tickformat = ",",
zeroline = FALSE))
# Jay Calvert
# Statistics and Analytical Services Branch
# Policy, Economics and Statistics Division
# DAERA
```