Charts

Row

Total Income from Farming

Total Income from Farming

Components of Total Income from Farming - Current terms

Average Sterling Exchange Rate

Farm Business Income

Farm Business Income - All Farms

Farm Business Income - Dairy and LFA cattle and Sheep Farms

Farm Performance - Dairy and Beef Cows

Average Gross Margin - Dairy Cows

Average Gross Margin - Beef Cows

Farm Performance - Breeding Ewes and Pigs

Average Gross Margin - Breeding ewes

Average Gross Margin - Pigs

Farm Performance - Crops

Average Gross Margin - Cereals

Average Gross Margin - Potatoes

Reader Information & Contact Details

Reader Information

These statistics are compiled from the Statistical Review of Northern Ireland Agriculture and Northern Ireland Farm Performance Indicators.

The Statistical Review of Northern Ireland Agriculture is a compendium of agri-food, environment and rural statistics that is published annually. It is an important reference document for both DAERA stakeholders and policy makers. The data contained in the Statistical Review are derived from farm surveys, as well as surveys of food processors and agricultural input supply firms, administrative data sources, and other environmental and rural data sources.

The Northern Ireland Farm Performance Indicators presents a range of physical and financial data for each of the main farm enterprises against which producers can assess the performance of their own enterprises.

Contact Details

DAERA Economics & Evaluation Branch is keen to hear your feedback.

Please e-mail comments to

Further information can be found on the DAERA Statistics website https://www.daera-ni.gov.uk/landing-pages/statistics

Row

```

---
title: " Northern Ireland Farm Incomes and Performance 1981-2022"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    theme: cerulean
    vertical_layout: scroll
    source_code: embed
    navbar:
      - { title: "Cookies", href: "https://www.daera-ni.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(plyr) 

# READ IN THE DATA
FIP <- read.csv("farm-income-data.csv", header = T, stringsAsFactors = F)    # Pick up the data from the database##

# TIDY THE DATA UP

kpis <- names(FIP)[c(3)]
FIPall <- melt(FIP, id=1:2)

FIPall$Sector[FIPall$Sector == "Gross Output"] <- "Gross Output"
FIPall$Sector[FIPall$Sector == "Gross Input"] <- "Gross Input"
FIPall$Sector[FIPall$Sector == "Gross value added"] <- "Gross value added"
FIPall$Sector[FIPall$Sector == "Total consumption of fixed capital"] <- "Total consumption of fixed capital"
FIPall$Sector[FIPall$Sector == "Other Subsidies (less taxes)"] <- "Other Subsidies"
FIPall$Sector[FIPall$Sector == "Net value added (at factor cost)"] <- "Net value added"
FIPall$Sector[FIPall$Sector == "Paid labour"] <- "Paid labour"
FIPall$Sector[FIPall$Sector == "Interest"] <- "Interest"
FIPall$Sector[FIPall$Sector == "Net rent"] <- "Net rent"
FIPall$Sector[FIPall$Sector == "Total income from farming"] <- "Total income from farming"
FIPall$Sector[FIPall$Sector == "Total income from farming real"] <- "Total income from farming real"
FIPall$Sector[FIPall$Sector == "Dairy"] <- "Dairy"
FIPall$Sector[FIPall$Sector == "LFA Cattle & Sheep"] <- "LFA Cattle and Sheep"
FIPall$Sector[FIPall$Sector == "All farms"] <- "All farms"
FIPall$Sector[FIPall$Sector == "Dairy Cows"] <- "Dairy Cows"
FIPall$Sector[FIPall$Sector == "Suckler Cows Non LFA"] <- "Suckler Cows Non LFA"
FIPall$Sector[FIPall$Sector == "Suckler Cows Disadvantaged Area"] <- "Suckler Cows Disadvantaged Area"
FIPall$Sector[FIPall$Sector == "Suckler Cows Severely Disadvantaged Area"] <- "Suckler Cows Severely Disadvantaged Area"
FIPall$Sector[FIPall$Sector == "Breeding Ewes Non LFA"] <- "Breeding Ewes Non LFA"
FIPall$Sector[FIPall$Sector == "Breeding Ewes Disadvantaged Area"] <- "Breeding Ewes Disadvantaged Area"
FIPall$Sector[FIPall$Sector == "Breeding Ewes SDA CrossBred Flocks"] <- "Breeding Ewes SDA CrossBred Flocks"
FIPall$Sector[FIPall$Sector == "Breeding Ewes SDA HardyHill Breeds"] <- "Breeding Ewes SDA HardyHill Breeds"
FIPall$Sector[FIPall$Sector == "Pigs Birth to Bacon"] <- "Pigs Birth to Bacon"
FIPall$Sector[FIPall$Sector == "Spring Barley"] <- "Spring Barley"
FIPall$Sector[FIPall$Sector == "Winter Wheat"] <- "Winter Wheat"
FIPall$Sector[FIPall$Sector == "Winter Barley"] <- "Winter Barley"
FIPall$Sector[FIPall$Sector == "Winter Oats"] <- "Winter Oats"
FIPall$Sector[FIPall$Sector == "Ware Potatoes"] <- "Ware Potatoes"


#format variables

FIPall$Sector  <- factor(FIPall$Sector)
FIPall$variable <- factor(FIPall$variable)

#FIPall$Year <- factor(FIPall$Year)
FIPall$value <- as.numeric(FIPall$value)


# CREATE FINAL DATAFRAME FOR SHARING
dat <- 
  FIPall %>%
  arrange(desc(Year))     #Arranging according years

# CREATE A COPY OF dat FOR GRAPHING THAT DOESN'T USE big.mark ","
dat_graph <- dat
dat$value <- sapply(dat$value, format, big.mark = ",")

# CROSSTALK
FIPkpis <-
  FIPall %>%
  filter(variable %in% kpis) %>%
  select(Year, Sector, variable, value) 

shared_dat <- SharedData$new(FIPkpis)
sd_df <- SharedData$new(FIPkpis, group = shared_dat$groupName())


# CREATE DATAFRAMES TO USE WITH PLOTLY

tidy_dat <- 
  dat_graph



###############################################
################# Total ####################
###############################################

Total <- 
  FIPall %>%
  filter(variable == "Total") %>%
  select(Year, Sector, value) %>% spread(Sector, value)


post1980 <-
  Total[as.numeric(as.character(Total$Year)) > 1980, ]

ticklabs <- list()



for(i in 1:length(Total$Year)){
  ticklabs[[i]] <- 1980+i
}


tickval <- list()

for(i in 1:length(Total$Year)){
  tickval[[i]] <- 1980+i
 
}


post1980<-post1980%>% mutate_if(is.numeric, round, digits=2)

```




```{r logo, out.width = "175px", echo=FALSE, fig.align='centre'} 

```


Charts {data-icon="fa-chart-line"}
===========================================================
Row {data-height=1050 .tabset .tabset-fade}
-------------------------------------

### **Total Income from Farming**

#### **Total Income from Farming**

```{r TIFF}

plot_ly(post1980, x = ~Year, y = ~`Total income from farming`, legendgroup = "tiff", name = 'Total income from farming - Current terms', type = 'scatter', mode = 'lines', visible = T, showlegend = T) %>% 
 add_trace(x = ~post1980$Year, y = ~post1980$`Total income from farming real`, legendgroup = "tiffreal", name = 'Total income from farming - Real terms', mode = 'lines', visible = T, showlegend = T) %>%
      
  layout(title = "",
         paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",hoverinfo="text",
         xaxis = list(title = "",
                      gridcolor = 'rgb(255,255,255)',
                      showgrid = FALSE,
                      range = c(1981, max(post1980$Year)),
                      ticktext = ticklabs,
                      tickvals = tickval,
                      showline = TRUE,
                      dtick = 1,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      zeroline = TRUE),
         yaxis = list(title = "£ million",
                      titlefont = list(size = 12),
                      gridcolor = 'rgb(229,229,299)',
                      range = c(0, max(Total$Value)),
                      showgrid = TRUE,
                      showline = TRUE,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      tickformat = ",",
                      zeroline = TRUE))

```

#### **Components of Total Income from Farming - Current terms**

```{r TIFFComponents}
plot_ly(post1980, x = ~Year, y = ~`Total income from farming`, legendgroup = "tiff", name = 'Total income from farming - Current', type = 'scatter', mode = 'lines', visible = T, showlegend = T) %>% 
   add_trace(x = ~post1980$Year, y = ~post1980$`Gross Output`, legendgroup = "output", name = 'Gross output', mode = 'lines', visible = T, showlegend = T) %>%
   add_trace(x = ~post1980$Year, y = ~post1980$`Gross Input`, legendgroup = "input", name = 'Gross input', mode = 'lines', visible = T, showlegend = T) %>%
   add_trace(x = ~post1980$Year, y = ~post1980$`Gross value added`, legendgroup = "grossval", name = 'Gross value added', mode = 'lines', visible = T, showlegend = T) %>%
   add_trace(x = ~post1980$Year, y = ~post1980$`Total consumption of fixed capital`, legendgroup = "capital", name = 'Total consumption of fixed capital', mode = 'lines', visible = T, showlegend = T) %>%
   add_trace(x = ~post1980$Year, y = ~post1980$`Other Subsidies`, legendgroup = "capital", name = 'Other Subsidies', mode = 'lines', visible = T, showlegend = T) %>%
   add_trace(x = ~post1980$Year, y = ~post1980$`Net value added`, legendgroup = "netval", name = 'Net value added', mode = 'lines', visible = T, showlegend = T) %>%
   add_trace(x = ~post1980$Year, y = ~post1980$`Paid labour`, legendgroup = "labour", name = 'Paid labour', mode = 'lines', visible = T, showlegend = T) %>%
  add_trace(x = ~post1980$Year, y = ~post1980$`Interest`, legendgroup = "interest", name = 'Interest', mode = 'lines', visible = T, showlegend = T) %>%
  add_trace(x = ~post1980$Year, y = ~post1980$`Net rent`, legendgroup = "rent", name = 'Net rent', mode = 'lines', visible = T, showlegend = T) %>%



  layout(title = "",
         paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",hoverinfo="text",
         xaxis = list(title = "",
                      gridcolor = 'rgb(255,255,255)',
                      showgrid = FALSE,
                      range = c(1981, max(post1980$Year)),
                      ticktext = ticklabs,
                      tickvals = tickval,
                      showline = TRUE,
                      dtick = 1,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      zeroline = F),
         yaxis = list(title = "£ million",
                      titlefont = list(size = 12),
                      gridcolor = 'rgb(229,229,299)',
                      range = c(0, max(Total$Value)),
                      showgrid = TRUE,
                      showline = TRUE,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      tickformat = ",",
                      zeroline = F))
```

### **Average Sterling Exchange Rate**

```{r Exchange Rate}
plot_ly(post1980, x = ~Year, y = ~`Pound to Euro`, legendgroup = "gbpeuro", name = 'Pound to Euro', type = 'scatter', mode = 'lines', visible = T, showlegend = T) %>% 
   add_trace(x = ~post1980$Year, y = ~post1980$`Pound to US Dollar`, legendgroup = "gbpdollar", name = 'Pound to US Dollar', mode = 'lines', visible = T, showlegend = T) %>%
   
  layout(legend = list(orientation = 'h', xanchor = "center", x = 0.5, y= -0.04))%>% 
  
  layout(autosize = F, height = 850)%>%
  


  layout(title = "",
         paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",hoverinfo="text",
         xaxis = list(title = "",
                      gridcolor = 'rgb(255,255,255)',
                      showgrid = FALSE,
                      range = c(1997, max(post1980$Year)),
                      ticktext = ticklabs,
                      tickvals = tickval,
                      showline = TRUE,
                      automargin = TRUE,
                      dtick = 1,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      zeroline = TRUE),
         yaxis = list(title = "Average Sterling Exchange Rate",
                      titlefont = list(size = 12),
                      gridcolor = 'rgb(229,229,299)',
                      range = c(0, max(Total$Value)),
                      showgrid = TRUE,
                      showline = TRUE,
                      automargin = TRUE,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      tickformat = ",",
                      zeroline = TRUE))
```


### **Farm Business Income**

#### **Farm Business Income - All Farms**


```{r Farm Incomes All farms}

plot_ly(post1980, x = ~Year, y = ~`All farms`, legendgroup = "allfarms", name = 'All farms',type = 'scatter', mode = 'lines', visible = T, showlegend = T) %>% 
  
    layout(showlegend = TRUE)%>% 
  
  layout(legend = list(orientation = 'h', xanchor = "center", x = 0.5))%>% 
  
  layout(title = "",
         paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",hoverinfo="text",
         xaxis = list(title = "",
                      gridcolor = 'rgb(255,255,255)',
                      showgrid = FALSE,
                      range = c(2003, max(post1980$Year)),
                      ticktext = ticklabs,
                      tickvals = tickval,
                      showline = TRUE,
                      dtick = 1,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      zeroline = TRUE),
         yaxis = list(title = "Average Farm Business Income (£ per farm)",
                      titlefont = list(size = 12),
                      gridcolor = 'rgb(229,229,299)',
                      range = c(0, max(Total$Value)),
                      rangemode = 'tozero',
                      showgrid = TRUE,
                      showline = TRUE,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      tickformat = ",",
                      zeroline = TRUE))

```

#### **Farm Business Income - Dairy and LFA cattle and Sheep Farms**


```{r Farm Incomes Dairy and LFA cattle and Sheep}

plot_ly(post1980, x = ~Year, y = ~`Dairy`, legendgroup = "dairy", name = 'Dairy', type = 'scatter', mode = 'lines', visible = T, showlegend = T) %>% 
  
 add_trace(x = ~post1980$Year, y = ~post1980$`LFA Cattle and Sheep`, legendgroup = "lfacatsheep", name = 'LFA Cattle & Sheep', mode = 'lines', visible = T, showlegend = T) %>%
   
  
  layout(legend = list(orientation = 'h', xanchor = "center", x = 0.5))%>% 
  

  layout(title = "",
         paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",hoverinfo="text",
         xaxis = list(title = "",
                      gridcolor = 'rgb(255,255,255)',
                      showgrid = FALSE,
                      range = c(2003, max(post1980$Year)),
                      ticktext = ticklabs,
                      tickvals = tickval,
                      showline = TRUE,
                      dtick = 1,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      zeroline = TRUE),
         yaxis = list(title = "Average Farm Business Income (£ per farm)",
                      titlefont = list(size = 12),
                      gridcolor = 'rgb(229,229,299)',
                      range = c(0, max(Total$Value)),
                      rangemode = 'tozero',
                      showgrid = TRUE,
                      showline = TRUE,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      tickformat = ",",
                      zeroline = TRUE))

```

### **Farm Performance - Dairy and Beef Cows**

#### **Average Gross Margin - Dairy Cows**

```{r Dairy Cows}

plot_ly(post1980, x = ~Year, y = ~`Dairy Cows`, legendgroup = "dairycows", name = 'Dairy Cows', type = 'scatter', mode = 'lines', visible = T, showlegend = T) %>% 
  
  layout(showlegend = TRUE)%>% 
  
  layout(legend = list(orientation = 'h', xanchor = "center", x = 0.5))%>% 
      
  layout(title = "",
         paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",hoverinfo="text",
         xaxis = list(title = "",
                      gridcolor = 'rgb(255,255,255)',
                      showgrid = FALSE,
                      range = c(2001, max(post1980$Year)),
                      ticktext = ticklabs,
                      tickvals = tickval,
                      showline = TRUE,
                      dtick = 1,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      zeroline = TRUE),
         yaxis = list(title = "Average Gross Margin (£ per head)",
                      titlefont = list(size = 12),
                      gridcolor = 'rgb(229,229,299)',
                      range = c(0, max(Total$Value)),
                      showgrid = TRUE,
                      showline = TRUE,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      tickformat = ",",
                      zeroline = TRUE))

```

#### **Average Gross Margin - Beef Cows**

```{r Beef Cows}

plot_ly(post1980, x = ~Year, y = ~`Suckler Cows Non LFA`, legendgroup = "sucklernonlfa", name = 'Suckler Cows Non LFA', type = 'scatter', mode = 'lines', visible = T, showlegend = T) %>% 
  
 add_trace(x = ~post1980$Year, y = ~post1980$`Suckler Cows Disadvantaged Area`, legendgroup = "sucklerda", name = 'Suckler Cows Disadvantaged Area', mode = 'lines', visible = T, showlegend = T) %>%
   add_trace(x = ~post1980$Year, y = ~post1980$`Suckler Cows Severely Disadvantaged Area`, legendgroup = "sucklersda", name = 'Suckler Cows Severely Disadvantaged Area', mode = 'lines', visible = T, showlegend = T) %>%
  
  layout(legend = list(orientation = 'h', xanchor = "center", x = 0.5))%>% 
      
  layout(title = "",
         paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",hoverinfo="text",
         xaxis = list(title = "",
                      gridcolor = 'rgb(255,255,255)',
                      showgrid = FALSE,
                      range = c(2001, max(post1980$Year)),
                      ticktext = ticklabs,
                      tickvals = tickval,
                      showline = TRUE,
                      dtick = 1,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      zeroline = TRUE),
         yaxis = list(title = "Average Gross Margin (£ per head)",
                      titlefont = list(size = 12),
                      gridcolor = 'rgb(229,229,299)',
                      range = c(0, max(Total$Value)),
                      showgrid = TRUE,
                      showline = TRUE,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      tickformat = ",",
                      zeroline = TRUE))

```

### **Farm Performance - Breeding Ewes and Pigs**

#### **Average Gross Margin - Breeding ewes**

```{r Breeding Ewes}

plot_ly(post1980, x = ~Year, y = ~`Breeding Ewes Non LFA`, legendgroup = "ewenlfa", name = 'Breeding Ewes Non LFA', type = 'scatter', mode = 'lines', visible = T, showlegend = T) %>% 
  
  add_trace(x = ~post1980$Year, y = ~post1980$`Breeding Ewes Disadvantaged Area`, legendgroup = "eweda", name = 'Breeding Ewes Disadvantaged Area', mode = 'lines', visible = T, showlegend = T) %>%
  add_trace(x = ~post1980$Year, y = ~post1980$`Breeding Ewes SDA CrossBred Flocks`, legendgroup = "ewesdacross", name = 'Breeding Ewes Severely Disadvantaged Area (Cross-Bred Flocks)', mode = 'lines', visible = T, showlegend = T) %>%
    add_trace(x = ~post1980$Year, y = ~post1980$`Breeding Ewes SDA HardyHill Breeds`, legendgroup = "ewesdahard", name = 'Breeding Ewes Severely Disadvantaged Area (Hardy Hill Breeds)', mode = 'lines', visible = T, showlegend = T) %>%
  
    layout(legend = list(orientation = 'h', xanchor = "center", x = 0.5))%>% 
    
    layout(title = "",
         paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",hoverinfo="text",
         xaxis = list(title = "",
                      gridcolor = 'rgb(255,255,255)',
                      showgrid = FALSE,
                      range = c(2001, max(post1980$Year)),
                      ticktext = ticklabs,
                      tickvals = tickval,
                      showline = TRUE,
                      dtick = 1,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      zeroline = TRUE),
         yaxis = list(title = "Average Gross Margin (£ per ewe)",
                      titlefont = list(size = 12),
                      gridcolor = 'rgb(229,229,299)',
                      range = c(0, max(Total$Value)),
                      showgrid = TRUE,
                      showline = TRUE,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      tickformat = ",",
                      zeroline = TRUE))

```

#### **Average Gross Margin - Pigs**

```{r Pigs}

plot_ly(post1980, x = ~Year, y = ~`Pigs Birth to Bacon`, legendgroup = "pigs", name = 'Pigs Birth to Bacon', type = 'scatter', mode = 'lines', visible = T, showlegend = T) %>% 
  
  layout(showlegend = TRUE)%>% 
  layout(legend = list(orientation = 'h', xanchor = "center", x = 0.5))%>% 
  
  
  layout(title = "",
         paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",hoverinfo="text",
         xaxis = list(title = "",
                      gridcolor = 'rgb(255,255,255)',
                      showgrid = FALSE,
                      range = c(2001, max(post1980$Year)),
                      ticktext = ticklabs,
                      tickvals = tickval,
                      showline = TRUE,
                      dtick = 1,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      zeroline = TRUE),
         yaxis = list(title = "Average Gross Margin (£ per finished pig)",
                      titlefont = list(size = 12),
                      gridcolor = 'rgb(229,229,299)',
                      range = c(0, max(Total$Value)),
                      showgrid = TRUE,
                      showline = TRUE,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      tickformat = ",",
                      zeroline = TRUE))

```

### **Farm Performance - Crops**

#### **Average Gross Margin - Cereals**

```{r Cereals}

plot_ly(post1980, x = ~Year, y = ~`Spring Barley`, legendgroup = "springbarley", name = 'Spring Barley', type = 'scatter', mode = 'lines', visible = T, showlegend = T) %>% 
  
  add_trace(x = ~post1980$Year, y = ~post1980$`Winter Wheat`, legendgroup = "wheat", name = 'Winter Wheat', mode = 'lines', visible = T, showlegend = T) %>%
  add_trace(x = ~post1980$Year, y = ~post1980$`Winter Barley`, legendgroup = "winterbarley", name = 'Winter Barley', mode = 'lines', visible = T, showlegend = T) %>%

  
  layout(legend = list(orientation = 'h', xanchor = "center", x = 0.5))%>% 
  
  layout(title = "",
         paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",hoverinfo="text",
         xaxis = list(title = "",
                      gridcolor = 'rgb(255,255,255)',
                      showgrid = FALSE,
                      range = c(2001, max(post1980$Year)),
                      ticktext = ticklabs,
                      tickvals = tickval,
                      showline = TRUE,
                      dtick = 1,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      zeroline = TRUE),
         yaxis = list(title = "£ per hectare",
                      titlefont = list(size = 12),
                      gridcolor = 'rgb(229,229,299)',
                      range = c(0, max(Total$Value)),
                      showgrid = TRUE,
                      showline = TRUE,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      tickformat = ",",
                      zeroline = TRUE))

```

#### **Average Gross Margin - Potatoes**

```{r Potatoes}

plot_ly(post1980, x = ~Year, y = ~`Ware Potatoes`, legendgroup = "potatoes", name = 'Ware Potatoes', type = 'scatter', mode = 'lines', visible = T, showlegend = T) %>% 
   layout(showlegend = TRUE)%>% 
  layout(legend = list(orientation = 'h', xanchor = "center", x = 0.5))%>% 
  
  layout(title = "",
         paper_bgcolor = 'rgb(255,255,255)', plot_bgcolor = 'rgb(255,255,255)', hovermode = "compare",hoverinfo="text",
         xaxis = list(title = "",
                      gridcolor = 'rgb(255,255,255)',
                      showgrid = FALSE,
                      range = c(2001, max(post1980$Year)),
                      ticktext = ticklabs,
                      tickvals = tickval,
                      showline = TRUE,
                      dtick = 1,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      zeroline = TRUE),
         yaxis = list(title = "£ per hectare",
                      titlefont = list(size = 12),
                      gridcolor = 'rgb(229,229,299)',
                      range = c(0, max(Total$Value)),
                      rangemode = 'tozero', 
                      showgrid = TRUE,
                      showline = TRUE,
                      showticklabels = TRUE,
                      tickcolor = 'rgb(127,127,127)',
                      ticks = 'outside',
                      tickformat = ",",
                      zeroline = TRUE))

```

Reader Information & Contact Details {data-icon="fa-chart-line"}
===========================================================

**Reader Information**

*These statistics are compiled from the Statistical Review of Northern Ireland Agriculture and Northern Ireland Farm Performance Indicators.*

*The Statistical Review of Northern Ireland Agriculture is a compendium of agri-food, environment and rural statistics that is published annually. It is an important reference document for both DAERA stakeholders and policy makers. The data contained in the Statistical Review are derived from farm surveys, as well as surveys of food processors and agricultural input supply firms, administrative data sources, and other environmental and rural data sources*.

*The Northern Ireland Farm Performance Indicators presents a range of physical and financial data for each of the main farm enterprises against which producers can assess the performance of their own enterprises.*

**Contact Details**

*DAERA Economics & Evaluation Branch is keen to hear your feedback.*

*Please e-mail comments to aeb.econstats@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}
-------------------------------------


```