---
title: "Mexican Tomatoes Are Winning American Domestic Markets"
author: "Wenjie Zhan & Yuhan Wang"
date: "`r Sys.Date()`"
output: pdf_document
fontsize: 12pt
mainfont: TimesNewRoman
indent: true
header-includes:
- \usepackage{setspace}\doublespacing
urlcolor: blue
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, include=TRUE, tidy=TRUE, warning=FALSE, message=FALSE, cache=FALSE)
rm(list=ls())
```
```{r}
library(openxlsx)
library(readxl)
library(dplyr)
library(ggplot2)
library(tidyr)
library(httr)
library(rnassqs)
```
The tomato originated in western South America and Central America and spread around the world following the [Columbian Exchange](https://scholar.harvard.edu/files/nunn/files/nunn_qian_jep_2010.pdf). Containing many health-promoting compounds, tomatoes are now one of the most-consumed fruits in the world. Americans eat about 20 pounds of fresh tomatoes per year, two-thirds of which now come from Mexico.
According to the Food and Agriculture Organization (FAO), worldwide production of fresh and processed tomatoes was 180.8 billion metric tons in 2019. China is the world’s largest producer of tomatoes, by far, followed by India, Turkey, the United States and Egypt. These top five countries produce 70% of global supply.
```{r}
## Get and clean tomato production data by countries from FAO
# Original source: http://www.fao.org/faostat/en/#data/QCL (accessed on 10/06/2021)
tmt_world<-read.table('https://files.asmith.ucdavis.edu/F1_2_FAOSTAT_data_tmt_prod_country_year.csv',sep = ",", header=TRUE)
```
```{r}
## Order countries for plotting
countries <- c("China","USA","India","Turkey","Egypt","Italy","Others")
country_order <- mutate(as.data.frame(countries),order=row_number()) %>%
rename(name=countries) %>%
mutate(order=ifelse(name=="China",1,order)) %>%
mutate(order=ifelse(name=="India",2,order)) %>%
mutate(order=ifelse(name=="Turkey",3,order)) %>%
mutate(order=ifelse(name=="USA",4,order)) %>%
mutate(order=ifelse(name=="Egypt",5,order)) %>%
mutate(order=ifelse(name=="Italy",6,order)) %>%
mutate(order=ifelse(name=="Others",7,order))
```
```{r}
# Create plot
plot_prod <- tmt_world %>%
filter(Area %in% c("World","China","United States of America", "India","Turkey","Egypt","Italy")) %>%
filter(Element=="Production") %>%
select(Year,Area,Value) %>%
pivot_wider(names_from = Area, values_from=Value, values_fill = 0) %>%
rename(USA=`United States of America`) %>%
mutate(Other=World-China-USA-India-Turkey-Egypt-Italy) %>%
select(-World) %>%
pivot_longer(-Year) %>%
left_join(country_order)%>%
mutate(value=value/1000000) %>%
ggplot(aes(x=Year,y=value,fill=reorder(name,order))) +
geom_area()+
labs(fill="Country", x = "Year", y = "Millions of Tons") +
theme_minimal()+
ggtitle(paste0("World Tomato Production"))+
theme(legend.position = "right",
legend.title = element_blank(),
plot.title = element_text(hjust = 0.5,size=16),
text = element_text(size=14))+
scale_fill_brewer(palette="Set3") # Set2
# draw and save plot
plot_prod
ggsave("tomato_world_production.png")
```
Source: FAOSTAT
The U.S. has the highest tomato yield among the top six tomato producers. Tomato yield in the U.S., which has almost quintupled over the past six decades, was about 100 metric tons per hectare in 2019.
```{r}
# Create plot
plot_yield <- tmt_world %>%
filter(Area %in% c("China","United States of America", "India","Turkey","Egypt","Italy")) %>%
filter(Element=="Yield") %>%
select(Year,Area,Value) %>%
pivot_wider(names_from = Area, values_from=Value, values_fill = 0) %>%
rename(USA=`United States of America`) %>%
pivot_longer(-Year) %>%
left_join(country_order)%>%
mutate(value=value/10000) %>%
ggplot(aes(x=Year,y=value,colour=name)) +
geom_line()+
labs(Colour="Country", x = "Year", y = "Tons/Hectare") +
theme_minimal()+
ggtitle(paste0("Tomato Yield by Top 6 Producers"))+
theme(legend.position = "right",
legend.title = element_blank(),
plot.title = element_text(hjust = 0.5,size=16),
text = element_text(size=14))+
scale_fill_brewer(palette="Set3") # Set2
# draw and save plot
plot_yield
ggsave("tomato_yield_top_producer.png")
```
Source: FAOSTAT
Tomato is a warm-season vegetable crop. California produces 90% of US tomatoes, about 4% of which go to the fresh market and the remainder into processing. Since 2015, USDA has only reported total tomato production for states outside California, likely because essentially all production in those states is for the fresh market.
Florida used to be the largest producer in the US fresh tomato market, but its production has diminished gradually since 2000. One of the main reasons is that the use of methyl bromide, a soil fumigant used to control pests, was banned in Florida. [Methyl bromide](https://www.wageningenacademic.com/doi/epdf/10.22434/IFAMR2018.0074) is blamed for depleting the earth’s protective ozone layer. In 2010, California surpassed Florida as the largest fresh tomato producer in the US. It now produces about 1 billion pounds per year.
```{r}
## Get the data from USDA https://usda.library.cornell.edu/concern/publications/j3860694x?locale=en (Accessed on 10/06/2021)
tmt_states<-read.table('https://files.asmith.ucdavis.edu/F3_USDA_tmt_prod_top_states.csv',sep = ",", header=TRUE)
```
```{r}
states <- c("CA","FL","IN","OH","MI","TN","SC","NJ","NC","VA")
# bar plot of production by state
state_plot <- tmt_states %>%
mutate(production = as.numeric(gsub(",", "", production))) %>%
mutate(processing = as.numeric(gsub(",", "", processing))) %>%
mutate(fresh = production-processing) %>%
rename(total=production) %>%
pivot_longer(-state) %>%
mutate(value=ifelse(state=="CA"&name=="total",NA,value))%>%
ggplot(aes(x=factor(state,levels=states),y=value/10000,fill=factor(name,levels=c("total","processing","fresh")))) +
geom_bar(stat="identity",position="stack")+
geom_text(aes(label = round(value/100)/100,digits=2), vjust = -0.5, size = 3)+
theme_minimal()+
ggtitle(paste0("US Tomato Production by State in 2018"))+
#scale_fill_brewer(palette = "Set2") +
labs(x="State",y="Billion Pounds",fill="Product")+
theme(plot.title = element_text(hjust = 0.5,size=16), text = element_text(size=14))
state_plot
ggsave("tmt_prod_by_states.png")
```
Source: USDA NASS 2020
In the last 25 years, US imports of tomatoes have risen by 6 times from 0.6 billion pounds to 4 billion pounds. Mexico has been by far the largest exporter of fresh tomatoes to the US with Canada a distant second. Both countries’ exports started to grow substantially after the North American Free Trade Agreement (NAFTA) signed in 1994. NAFTA was replaced by the United States–Mexico–Canada Agreement, or USMCA in short, on July 1st, 2020, with only small changes in provisions.
From 1994 to 1995, the volume of imported fresh tomatoes from Mexico jumped from 0.8 billion pounds to 1.3 billion pounds, which amounts to a 50% growth. Imports from Mexico continued to grow dramatically in the following decades, and reached 3.7 billion pounds in 2020, which accounts for 90.7% of US total imports of tomatoes.
```{r}
##
tmt_import<-read.table('https://files.asmith.ucdavis.edu/F5_6_tmt_import.csv',sep = ",", header=TRUE)
```
```{r}
import_plot<-tmt_import%>%
rename(Mexico='Import.from.Mexico.by.volume..Million.pounds.', Canada = 'Import.from.Canada.by.volume..Million.pounds.', Other = 'Import.from.others.by.volume..Million.pounds.')%>%
select(Year, Mexico, Canada, Other) %>%
gather(region, import, Mexico:Other, factor_key=TRUE)%>%
filter(!is.na(import))%>%
mutate(import = as.numeric(gsub(",", "", import))) %>%
ggplot(aes(x=Year,y=import/1000,fill=factor(region,levels=c("Other","Canada","Mexico")))) +
geom_bar(stat="identity",position="stack")+
geom_vline(xintercept=1994,size=1,color="black") +
geom_text(x=1997, y=4, label="NAFTA",size=3) +
theme_minimal()+
ggtitle("US Tomato Imports by Source") +
scale_fill_brewer(palette = "Set2") +
labs(x="Year",y="Billion Pounds",fill="Country")+
theme(plot.title = element_text(hjust = 0.5,size=16), text = element_text(size=14))
import_plot
ggsave("tmt_import_by_countries.png")
```
Source: USDA
In contrast, US fresh-market tomato production has declined substantially from 4.3 billion pounds in 2002, the year when US domestic production peaked, to 2.5 billion pounds in 2020. In 2016, US domestic tomato production was surpassed by imports for the first time. After that, the gap between domestic production and imports grows further, amounting to 1.4 billion pounds in 2020. US processing tomato production remains at 1995 levels, although it has declined 20% in the last five years after increasing from 1995-2015.
```{r}
improd_plot<-tmt_import%>%
#mutate(Net_Import= Imports - Exports)%>%
select(Year, Imports, Production) %>%
gather(improd, value, Production:Imports, factor_key=TRUE)%>%
mutate(value = as.numeric(gsub(",", "", value))) %>%
ggplot(aes(x=Year,y=value/1000,fill=factor(improd,levels=c("Imports","Production")))) +
geom_bar(stat="identity",position="dodge")+
geom_vline(xintercept=1994,size=1,color="black") +
geom_text(x=1997, y=4.2, label="NAFTA",size=3) +
theme_minimal()+
ggtitle("US Fresh Tomato Imports and Production")+
scale_fill_brewer(palette = "Set1") +
labs(x="Year",y="Billion Pounds",fill="improd")+
theme(legend.title = element_blank(),
plot.title = element_text(hjust = 0.5,size=16),
text = element_text(size=14))
improd_plot
ggsave("tmt_net_import_prod_comparison.png")
```
Source: USDA Vegetables and Pulses Yearbook Tables
NAFTA eliminated trade barriers for most agricultural products, and since that time US fresh tomato production has declined by almost 50%. Similarly to [avocados](https://asmith.ucdavis.edu/news/california-avocado-hass-taken-over-world), US fresh tomato producers are losing ground to their Mexican counterpart, whose production and exports are still expanding rapidly.