[1] MyApps Portal (2019) Instructure.com. Available at: https://rmit.instructure.com/courses/124254/modules.
[2]Australian Agricultural Productivity - Broadacre and Dairy Estimates - DAFF. (2021). Agriculture.gov.au. https://www.agriculture.gov.au/abares/research-topics/productivity/agricultural-productivity-estimates#daff-page-main
---
title: "Agricultural Productivity and Efficiency in Australia"
author: "Mayank Nagpal"
output:
flexdashboard::flex_dashboard:
orientation: columns
social: menu
source_code: embed
---
```{r setup, include=FALSE}
library(readxl)
library(dplyr)
library(ggplot2)
library(flexdashboard)
library(viridisLite)
library(plotly)
library(highcharter)
thm <-
hc_theme(
colors = c("#1a6ecc", "#434348", "#90ed7d"),
chart = list(
backgroundColor = "transparent",
style = list(fontFamily = "Source Sans Pro")
),
xAxis = list(
gridLineWidth = 1
)
)
```
```{r}
# Load data from Excel
vic_cropping <- read_excel("/Users/mayanknagpal/My_Folder/Semester2/Data Visualization/Assignment 3/New/New_main.xlsx", sheet = "VIC_Cropping")
nsw_cropping <- read_excel("/Users/mayanknagpal/My_Folder/Semester2/Data Visualization/Assignment 3/New/New_main.xlsx", sheet = "NSW_Cropping")
qld_cropping <- read_excel("/Users/mayanknagpal/My_Folder/Semester2/Data Visualization/Assignment 3/New/New_main.xlsx", sheet = "QLD_Cropping")
sa_cropping <- read_excel("/Users/mayanknagpal/My_Folder/Semester2/Data Visualization/Assignment 3/New/New_main.xlsx", sheet = "SA_Cropping")
wa_cropping <- read_excel("/Users/mayanknagpal/My_Folder/Semester2/Data Visualization/Assignment 3/New/New_main.xlsx", sheet = "WA_Cropping")
# Add a column to indicate the state
vic_cropping$State <- "VIC"
nsw_cropping$State <- "NSW"
qld_cropping$State <- "QLD"
sa_cropping$State <- "SA"
wa_cropping$State <- "WA"
# Combine all data into one data frame
cropping_data <- bind_rows(vic_cropping, nsw_cropping, qld_cropping, sa_cropping, wa_cropping)
```
<br>
Trend Analysis
=====================================
Row {.tabset data-width=400}
-----------------------------------------------------------------------
### Input Trend
```{r}
# R code for Input Trend
input_plot <- plot_ly(cropping_data, x = ~Year, y = ~Output, color = ~State, type = 'scatter', mode = 'lines+markers') %>%
layout(title = "Input Trend Over the Years by State",
xaxis = list(title = "Year<br><sub>- Input: Aggregate index of all farm inputs.</sub> "),
yaxis = list(title = "Input")
)
input_plot
```
### Output Trend
```{r}
# Output Trend
output_plot <- plot_ly(cropping_data, x = ~Year, y = ~Output, color = ~State, type = 'scatter', mode = 'lines+markers') %>%
layout(title = "Output Trend Over the Years by State",
xaxis = list(title = "Year<br><sub>- Output: Aggregate index of all farm outputs. </sub>"),
yaxis = list(title = "Output"))
output_plot
```
### TFP Trend
```{r}
# TFP Trend
tfp_plot <- plot_ly(cropping_data, x = ~Year, y = ~TFP, color = ~State, type = 'scatter', mode = 'lines+markers') %>%
layout(title = "TFP Trend Over the Years by State",
xaxis = list(title = "Year<br><sub>- TFP: Aggregate index of Total Factor Productivity (TFP). </sub>"),
yaxis = list(title = "TFP"))
tfp_plot
```
State Comparison
=====================================
Row {.tabset data-width=400}
-----------------------------------------------------------------------
### Average Input by state
```{r}
# Calculate averages
avg_data <- cropping_data %>%
group_by(State) %>%
summarise(avg_Input = mean(Input),
avg_Output = mean(Output),
avg_TFP = mean(TFP))
# Input Bar Chart
input_bar_chart <- plot_ly(avg_data, x = ~State, y = ~avg_Input, type = 'bar', color = ~State) %>%
layout(title = "Average Input by State",
yaxis = list(title = "Average Input"),
xaxis = list(title = "State<br><sub>- Input: Aggregate index of all farm inputs.</sub> "))
input_bar_chart
```
### Average Output by state
```{r}
# Output Bar Chart
output_bar_chart <- plot_ly(avg_data, x = ~State, y = ~avg_Output, type = 'bar', color = ~State) %>%
layout(title = "Average Output by State",
yaxis = list(title = "Average Output"),
xaxis = list(title = "State<br><sub>- Output: Aggregate index of all farm outputs. </sub>")
)
output_bar_chart
```
### Average TFP by state
```{r}
# TFP Bar Chart
tfp_bar_chart <- plot_ly(avg_data, x = ~State, y = ~avg_TFP, type = 'bar', color = ~State) %>%
layout(title = "Average TFP by State",
yaxis = list(title = "Average TFP"),
xaxis = list(title = "State<br><sub>- TFP: Aggregate index of Total Factor Productivity (TFP). </sub>"))
tfp_bar_chart
```
Efficiency Analysis
=====================================
Row {.tabset data-width=400}
----------------------------------------------------------------------
### TFP Change by state
```{r}
# Interactive Line Chart with Markers for TFP Changes
tfp_line_chart <- plot_ly(cropping_data, x = ~Year, y = ~TFP, color = ~State, type = 'scatter', mode = 'lines+markers') %>%
layout(title = "TFP Change Over the Years by State ",
xaxis = list(title = "Year<br><sub>- TFP: Aggregate index of Total Factor Productivity (TFP). </sub>"),
yaxis = list(title = "TFP"))
tfp_line_chart
```
References
=====================================
[1] MyApps Portal (2019) Instructure.com. Available at: https://rmit.instructure.com/courses/124254/modules.
[2]Australian Agricultural Productivity - Broadacre and Dairy Estimates - DAFF. (2021). Agriculture.gov.au. https://www.agriculture.gov.au/abares/research-topics/productivity/agricultural-productivity-estimates#daff-page-main