Bangladesh is an agricultural country.Like many other agricultural products, tomato plays an important role in the economy of Bangladesh.Bangladesh is the 45th country in producing tomatoes among countries all over the world. In this project, the production and value that was earned from tomatoes since 1961 to 2023, in Bangladesh have been analyzed.

Importing data according to Food & Agricultural Organization(FAO)

library(readxl)
FAOSTAT_data_Tomato_Production_in_Bangladesh <- read_excel("FAOSTAT_data_Tomato_Production_in_Bangladesh.xls")
View(FAOSTAT_data_Tomato_Production_in_Bangladesh)

Static visualization (Value earned from Tomato by year)

library(ggplot2)
Tomato<-ggplot(FAOSTAT_data_Tomato_Production_in_Bangladesh,aes(x=Year,y=Value_In_Dollar))+
  geom_point(color="Green",alpha=10) + 
  labs(x = "Year", y = "Value in dollar") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1),
    axis.title.x = element_text(size = 10, face = "plain"))
 Tomato

Changing Title and axis titles

Tomato+labs(title="Yearly value earned from Tomatoes", 
       subtitle="In Bangladesh", 
       y="'Value_In_Dollar", 
       x="Year", 
       caption="Earning from Agricultural product")

The price or the value of tomato depends heavily on the production quantity every year. Hence to compare the relationship between production quantity and value,another scatter plot is created below:

Price_vs_quantity<-ggplot(FAOSTAT_data_Tomato_Production_in_Bangladesh,aes(x=Production_Quantity_In_Tons,y=Value_In_Dollar))+
  geom_point(color="Green",alpha=10) + 
  labs(x = "Quantity", y = "Value in dollar") +
  theme(axis.text.x = element_text(angle = 45, hjust = 1),
    axis.title.x = element_text(size = 10, face = "plain"))
Price_vs_quantity

From a regression line it can be clearly visualized whether value and production quantity are positively related or negatively related.Hence, a regression line is generated below:

Tom<-Price_vs_quantity+
  geom_smooth(method ="lm")
Tom
## `geom_smooth()` using formula = 'y ~ x'

Making the plot interactive

library(plotly)
## Warning: package 'plotly' was built under R version 4.4.3
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
ggplotly(Tom)
## `geom_smooth()` using formula = 'y ~ x'

Identifying the structure of the data frame:

str(FAOSTAT_data_Tomato_Production_in_Bangladesh)
## tibble [63 × 4] (S3: tbl_df/tbl/data.frame)
##  $ Item                       : chr [1:63] "Tomatoes" "Tomatoes" "Tomatoes" "Tomatoes" ...
##  $ Year                       : chr [1:63] "1961" "1962" "1963" "1964" ...
##  $ Value_In_Dollar            : num [1:63] 16101 15399 15819 16832 18181 ...
##  $ Production_Quantity_In_Tons: num [1:63] 6743 14121 13107 8868 12780 ...

Creating an animation about the tomato market in Bangladesh observing the change of value per year:

library(gganimate)
## Warning: package 'gganimate' was built under R version 4.4.3
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ lubridate 1.9.4     ✔ tibble    3.2.1
## ✔ purrr     1.0.4     ✔ tidyr     1.3.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks plotly::filter(), stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
FAOSTAT_data_Tomato_Production_in_Bangladesh$Year <- as.numeric(as.character(FAOSTAT_data_Tomato_Production_in_Bangladesh$Year))
BD_Tomato<-FAOSTAT_data_Tomato_Production_in_Bangladesh %>% 
  ggplot(aes(Year, Value_In_Dollar, color=Value_In_Dollar,group = 1)) +
  geom_line() +
  labs(title = 'Year: {frame_time}', x = 'Year', y = 'Value_in_dollar') +
  #here comes the gganimate code
  transition_reveal(Year) +
  ease_aes('linear')+
  theme_minimal()

BD_Tomato
## `geom_line()`: Each group consists of only one observation.
## ℹ Do you need to adjust the group aesthetic?
## `geom_line()`: Each group consists of only one observation.
## ℹ Do you need to adjust the group aesthetic?

Saving the animation in desired path

a <- animate(BD_Tomato, fps=5, renderer = av_renderer())
## `geom_line()`: Each group consists of only one observation.
## ℹ Do you need to adjust the group aesthetic?
## `geom_line()`: Each group consists of only one observation.
## ℹ Do you need to adjust the group aesthetic?
anim_save("Tomato_Market_Of_Bangladesh.mp4", a, path = 'C:/Users/DELL/Downloads' )

From this project we can interpret that there is a postive change in earning value from producing tomato in Bangladesh.It also illustrates that though since 1960 to 2000 Bangladesh was earning less but the market still had a growth.Between 2000 to 2023 the market was at the peak which showing continuous progress in tomato production.