TourismDeforestationSubmission / 000_ConfounderCompilation.Rmd
000_ConfounderCompilation.Rmd
Raw
---
title: "01_ConfounderCompilation"
author: "Camille"
date: "3/1/2023"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r}
library(tidyverse); library(readxl)
#replaced ~/Documents with ~/Documents
#replaced dplyr::select with dplyr::select

area_dat <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/MPA_PA_area4.xlsx")
area_dat_commune <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/MPA_commune_area.xlsx")

```

```{r Precipitation Compilation-- Full}
###IMPORT   MONTHLY PRECIPITATION DATA
#2000
mada_2000_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2000_01AllFull.xls")
mada_2000_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2000_02AllFull.xls")
mada_2000_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2000_03AllFull.xls")
mada_2000_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2000_04AllFull.xls")
mada_2000_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2000_05AllFull.xls")
mada_2000_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2000_06AllFull.xls")
mada_2000_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2000_07AllFull.xls")
mada_2000_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2000_08AllFull.xls")
mada_2000_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2000_09AllFull.xls")
mada_2000_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2000_10AllFull.xls")
mada_2000_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2000_11AllFull.xls")
mada_2000_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2000_12AllFull.xls")
#2001
mada_2001_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2001_01AllFull.xls")
mada_2001_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2001_02AllFull.xls")
mada_2001_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2001_03AllFull.xls")
mada_2001_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2001_04AllFull.xls")
mada_2001_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2001_05AllFull.xls")
mada_2001_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2001_06AllFull.xls")
mada_2001_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2001_07AllFull.xls")
mada_2001_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2001_08AllFull.xls")
mada_2001_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2001_09AllFull.xls")
mada_2001_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2001_10AllFull.xls")
mada_2001_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2001_11AllFull.xls")
mada_2001_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2001_12AllFull.xls")
#2002
mada_2002_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2002_01AllFull.xls")
mada_2002_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2002_02AllFull.xls")
mada_2002_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2002_03AllFull.xls")
mada_2002_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2002_04AllFull.xls")
mada_2002_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2002_05AllFull.xls")
mada_2002_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2002_06AllFull.xls")
mada_2002_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2002_07AllFull.xls")
mada_2002_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2002_08AllFull.xls")
mada_2002_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2002_09AllFull.xls")
mada_2002_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2002_10AllFull.xls")
mada_2002_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2002_11AllFull.xls")
mada_2002_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2002_12AllFull.xls")
#2003
mada_2003_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2003_01AllFull.xls")
mada_2003_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2003_02AllFull.xls")
mada_2003_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2003_03AllFull.xls")
mada_2003_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2003_04AllFull.xls")
mada_2003_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2003_05AllFull.xls")
mada_2003_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2003_06AllFull.xls")
mada_2003_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2003_07AllFull.xls")
mada_2003_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2003_08AllFull.xls")
mada_2003_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2003_09AllFull.xls")
mada_2003_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2003_10AllFull.xls")
mada_2003_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2003_11AllFull.xls")
mada_2003_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2003_12AllFull.xls")
#2004
mada_2004_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2004_01AllFull.xls")
mada_2004_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2004_02AllFull.xls")
mada_2004_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2004_03AllFull.xls")
mada_2004_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2004_04AllFull.xls")
mada_2004_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2004_05AllFull.xls")
mada_2004_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2004_06AllFull.xls")
mada_2004_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2004_07AllFull.xls")
mada_2004_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2004_08AllFull.xls")
mada_2004_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2004_09AllFull.xls")
mada_2004_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2004_10AllFull.xls")
mada_2004_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2004_11AllFull.xls")
mada_2004_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2004_12AllFull.xls")
#2005
mada_2005_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2005_01AllFull.xls")
mada_2005_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2005_02AllFull.xls")
mada_2005_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2005_03AllFull.xls")
mada_2005_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2005_04AllFull.xls")
mada_2005_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2005_05AllFull.xls")
mada_2005_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2005_06AllFull.xls")
mada_2005_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2005_07AllFull.xls")
mada_2005_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2005_08AllFull.xls")
mada_2005_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2005_09AllFull.xls")
mada_2005_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2005_10AllFull.xls")
mada_2005_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2005_11AllFull.xls")
mada_2005_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2005_12AllFull.xls")
#2006
mada_2006_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2006_01AllFull.xls")
mada_2006_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2006_02AllFull.xls")
mada_2006_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2006_03AllFull.xls")
mada_2006_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2006_04AllFull.xls")
mada_2006_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2006_05AllFull.xls")
mada_2006_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2006_06AllFull.xls")
mada_2006_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2006_07AllFull.xls")
mada_2006_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2006_08AllFull.xls")
mada_2006_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2006_09AllFull.xls")
mada_2006_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2006_10AllFull.xls")
mada_2006_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2006_11AllFull.xls")
mada_2006_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2006_12AllFull.xls")
#2007
mada_2007_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2007_01AllFull.xls")
mada_2007_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2007_02AllFull.xls")
mada_2007_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2007_03AllFull.xls")
mada_2007_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2007_04AllFull.xls")
mada_2007_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2007_05AllFull.xls")
mada_2007_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2007_06AllFull.xls")
mada_2007_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2007_07AllFull.xls")
mada_2007_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2007_08AllFull.xls")
mada_2007_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2007_09AllFull.xls")
mada_2007_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2007_10AllFull.xls")
mada_2007_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2007_11AllFull.xls")
mada_2007_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2007_12AllFull.xls")
#2008
mada_2008_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2008_01AllFull.xls")
mada_2008_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2008_02AllFull.xls")
mada_2008_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2008_03AllFull.xls")
mada_2008_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2008_04AllFull.xls")
mada_2008_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2008_05AllFull.xls")
mada_2008_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2008_06AllFull.xls")
mada_2008_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2008_07AllFull.xls")
mada_2008_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2008_08AllFull.xls")
mada_2008_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2008_09AllFull.xls")
mada_2008_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2008_10AllFull.xls")
mada_2008_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2008_11AllFull.xls")
mada_2008_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2008_12AllFull.xls")
#2009
mada_2009_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2009_01AllFull.xls")
mada_2009_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2009_02AllFull.xls")
mada_2009_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2009_03AllFull.xls")
mada_2009_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2009_04AllFull.xls")
mada_2009_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2009_05AllFull.xls")
mada_2009_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2009_06AllFull.xls")
mada_2009_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2009_07AllFull.xls")
mada_2009_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2009_08AllFull.xls")
mada_2009_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2009_09AllFull.xls")
mada_2009_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2009_10AllFull.xls")
mada_2009_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2009_11AllFull.xls")
mada_2009_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2009_12AllFull.xls")
#2010
mada_2010_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2010_01AllFull.xls")
mada_2010_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2010_02AllFull.xls")
mada_2010_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2010_03AllFull.xls")
mada_2010_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2010_04AllFull.xls")
mada_2010_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2010_05AllFull.xls")
mada_2010_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2010_06AllFull.xls")
mada_2010_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2010_07AllFull.xls")
mada_2010_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2010_08AllFull.xls")
mada_2010_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2010_09AllFull.xls")
mada_2010_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2010_10AllFull.xls")
mada_2010_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2010_11AllFull.xls")
mada_2010_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2010_12AllFull.xls")
#2011
mada_2011_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2011_01AllFull.xls")
mada_2011_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2011_02AllFull.xls")
mada_2011_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2011_03AllFull.xls")
mada_2011_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2011_04AllFull.xls")
mada_2011_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2011_05AllFull.xls")
mada_2011_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2011_06AllFull.xls")
mada_2011_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2011_07AllFull.xls")
mada_2011_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2011_08AllFull.xls")
mada_2011_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2011_09AllFull.xls")
mada_2011_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2011_10AllFull.xls")
mada_2011_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2011_11AllFull.xls")
mada_2011_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2011_12AllFull.xls")
#2012
mada_2012_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2012_01AllFull.xls")
mada_2012_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2012_02AllFull.xls")
mada_2012_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2012_03AllFull.xls")
mada_2012_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2012_04AllFull.xls")
mada_2012_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2012_05AllFull.xls")
mada_2012_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2012_06AllFull.xls")
mada_2012_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2012_07AllFull.xls")
mada_2012_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2012_08AllFull.xls")
mada_2012_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2012_09AllFull.xls")
mada_2012_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2012_10AllFull.xls")
mada_2012_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2012_11AllFull.xls")
mada_2012_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2012_12AllFull.xls")
#2013
mada_2013_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2013_01AllFull.xls")
mada_2013_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2013_02AllFull.xls")
mada_2013_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2013_03AllFull.xls")
mada_2013_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2013_04AllFull.xls")
mada_2013_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2013_05AllFull.xls")
mada_2013_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2013_06AllFull.xls")
mada_2013_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2013_07AllFull.xls")
mada_2013_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2013_08AllFull.xls")
mada_2013_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2013_09AllFull.xls")
mada_2013_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2013_10AllFull.xls")
mada_2013_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2013_11AllFull.xls")
mada_2013_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2013_12AllFull.xls")
#2014
mada_2014_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2014_01AllFull.xls")
mada_2014_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2014_02AllFull.xls")
mada_2014_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2014_03AllFull.xls")
mada_2014_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2014_04AllFull.xls")
mada_2014_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2014_05AllFull.xls")
mada_2014_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2014_06AllFull.xls")
mada_2014_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2014_07AllFull.xls")
mada_2014_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2014_08AllFull.xls")
mada_2014_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2014_09AllFull.xls")
mada_2014_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2014_10AllFull.xls")
mada_2014_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2014_11AllFull.xls")
mada_2014_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2014_12AllFull.xls")
#2015
mada_2015_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2015_01AllFull.xls")
mada_2015_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2015_02AllFull.xls")
mada_2015_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2015_03AllFull.xls")
mada_2015_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2015_04AllFull.xls")
mada_2015_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2015_05AllFull.xls")
mada_2015_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2015_06AllFull.xls")
mada_2015_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2015_07AllFull.xls")
mada_2015_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2015_08AllFull.xls")
mada_2015_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2015_09AllFull.xls")
mada_2015_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2015_10AllFull.xls")
mada_2015_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2015_11AllFull.xls")
mada_2015_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2015_12AllFull.xls")
#2016
mada_2016_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2016_01AllFull.xls")
mada_2016_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2016_02AllFull.xls")
mada_2016_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2016_03AllFull.xls")
mada_2016_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2016_04AllFull.xls")
mada_2016_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2016_05AllFull.xls")
mada_2016_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2016_06AllFull.xls")
mada_2016_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2016_07AllFull.xls")
mada_2016_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2016_08AllFull.xls")
mada_2016_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2016_09AllFull.xls")
mada_2016_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2016_10AllFull.xls")
mada_2016_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2016_11AllFull.xls")
mada_2016_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2016_12AllFull.xls")
#2017
mada_2017_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2017_01AllFull.xls")
mada_2017_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2017_02AllFull.xls")
mada_2017_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2017_03AllFull.xls")
mada_2017_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2017_04AllFull.xls")
mada_2017_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2017_05AllFull.xls")
mada_2017_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2017_06AllFull.xls")
mada_2017_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2017_07AllFull.xls")
mada_2017_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2017_08AllFull.xls")
mada_2017_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2017_09AllFull.xls")
mada_2017_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2017_10AllFull.xls")
mada_2017_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2017_11AllFull.xls")
mada_2017_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2017_12AllFull.xls")
#2018
mada_2018_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2018_01AllFull.xls")
mada_2018_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2018_02AllFull.xls")
mada_2018_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2018_03AllFull.xls")
mada_2018_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2018_04AllFull.xls")
mada_2018_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2018_05AllFull.xls")
mada_2018_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2018_06AllFull.xls")
mada_2018_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2018_07AllFull.xls")
mada_2018_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2018_08AllFull.xls")
mada_2018_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2018_09AllFull.xls")
mada_2018_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2018_10AllFull.xls")
mada_2018_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2018_11AllFull.xls")
mada_2018_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation2/PrecPoints_prec_2018_12AllFull.xls")
#2019
mada_2019_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-01AllFull.xls")
mada_2019_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-02AllFull.xls")
mada_2019_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-03AllFull.xls")
mada_2019_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-04AllFull.xls")
mada_2019_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-05AllFull.xls")
mada_2019_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-06AllFull.xls")
mada_2019_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-07AllFull.xls")
mada_2019_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-08AllFull.xls")
mada_2019_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-09AllFull.xls")
mada_2019_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-10AllFull.xls")
mada_2019_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-11AllFull.xls")
mada_2019_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-12AllFull.xls")
#2020
mada_2020_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-01AllFull.xls")
mada_2020_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-02AllFull.xls")
mada_2020_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-03AllFull.xls")
mada_2020_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-04AllFull.xls")
mada_2020_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-05AllFull.xls")
mada_2020_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-06AllFull.xls")
mada_2020_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-07AllFull.xls")
mada_2020_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-08AllFull.xls")
mada_2020_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-09AllFull.xls")
mada_2020_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-10AllFull.xls")
mada_2020_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-11AllFull.xls")
mada_2020_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-12AllFull.xls")
#2021
mada_2021_1_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-01AllFull.xls")
mada_2021_2_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-02AllFull.xls")
mada_2021_3_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-03AllFull.xls")
mada_2021_4_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-04AllFull.xls")
mada_2021_5_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-05AllFull.xls")
mada_2021_6_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-06AllFull.xls")
mada_2021_7_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-07AllFull.xls")
mada_2021_8_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-08AllFull.xls")
mada_2021_9_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-09AllFull.xls")
mada_2021_10_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-10AllFull.xls")
mada_2021_11_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-11AllFull.xls")
mada_2021_12_precip <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-12AllFull.xls")

###COMPILE MONTHLY PRECIPITATION DATA BY YEAR 
mada_2000_precip <- rbind(mada_2000_1_precip, mada_2000_2_precip, mada_2000_3_precip, mada_2000_4_precip, mada_2000_5_precip, mada_2000_6_precip, mada_2000_7_precip, mada_2000_8_precip, mada_2000_9_precip, mada_2000_10_precip, mada_2000_11_precip, mada_2000_12_precip)
mada_2000_precip$Year <- 2000


mada_2001_precip <- rbind(mada_2001_1_precip, mada_2001_2_precip, mada_2001_3_precip, mada_2001_4_precip, mada_2001_5_precip, mada_2001_6_precip, mada_2001_7_precip, mada_2001_8_precip, mada_2001_9_precip, mada_2001_10_precip, mada_2001_11_precip, mada_2001_12_precip)
mada_2001_precip$Year <- 2001

mada_2002_precip <- rbind(mada_2002_1_precip, mada_2002_2_precip, mada_2002_3_precip, mada_2002_4_precip, mada_2002_5_precip, mada_2002_6_precip, mada_2002_7_precip, mada_2002_8_precip, mada_2002_9_precip, mada_2002_10_precip, mada_2002_11_precip, mada_2002_12_precip)
mada_2002_precip$Year <- 2002

mada_2003_precip <- rbind(mada_2003_1_precip, mada_2003_2_precip, mada_2003_3_precip, mada_2003_4_precip, mada_2003_5_precip, mada_2003_6_precip, mada_2003_7_precip, mada_2003_8_precip, mada_2003_9_precip, mada_2003_10_precip, mada_2003_11_precip, mada_2003_12_precip)
mada_2003_precip$Year <- 2003

mada_2004_precip <- rbind(mada_2004_1_precip, mada_2004_2_precip, mada_2004_3_precip, mada_2004_4_precip,  mada_2004_6_precip, mada_2004_7_precip, mada_2004_8_precip, mada_2004_9_precip, mada_2004_10_precip, mada_2004_11_precip, mada_2004_12_precip)
mada_2004_precip$Year <- 2004

mada_2005_precip <- rbind(mada_2005_1_precip, mada_2005_2_precip, mada_2005_3_precip, mada_2005_4_precip, mada_2005_5_precip, mada_2005_6_precip, mada_2005_7_precip, mada_2005_8_precip, mada_2005_9_precip, mada_2005_10_precip, mada_2005_11_precip, mada_2005_12_precip)
mada_2005_precip$Year <- 2005

mada_2006_precip <- rbind(mada_2006_1_precip, mada_2006_2_precip, mada_2006_3_precip, mada_2006_4_precip, mada_2006_5_precip, mada_2006_6_precip, mada_2006_7_precip, mada_2006_8_precip, mada_2006_9_precip, mada_2006_10_precip, mada_2006_11_precip, mada_2006_12_precip)
mada_2006_precip$Year <- 2006

mada_2007_precip <- rbind(mada_2007_1_precip, mada_2007_2_precip, mada_2007_3_precip, mada_2007_4_precip, mada_2007_5_precip, mada_2007_6_precip, mada_2007_8_precip, mada_2007_9_precip, mada_2007_10_precip, mada_2007_11_precip, mada_2007_12_precip)
mada_2007_precip$Year <- 2007

mada_2008_precip <- rbind(mada_2008_1_precip, mada_2008_2_precip, mada_2008_3_precip, mada_2008_4_precip, mada_2008_5_precip, mada_2008_6_precip, mada_2008_7_precip, mada_2008_8_precip, mada_2008_9_precip, mada_2008_10_precip, mada_2008_11_precip, mada_2008_12_precip)
mada_2008_precip$Year <- 2008

mada_2009_precip <- rbind(mada_2009_1_precip, mada_2009_2_precip, mada_2009_3_precip, mada_2009_4_precip, mada_2009_5_precip, mada_2009_6_precip, mada_2009_7_precip, mada_2009_8_precip, mada_2009_9_precip, mada_2009_10_precip, mada_2009_11_precip, mada_2009_12_precip)
mada_2009_precip$Year <- 2009

mada_2010_precip <- rbind(mada_2010_1_precip, mada_2010_2_precip, mada_2010_3_precip, mada_2010_4_precip, mada_2010_5_precip, mada_2010_6_precip, mada_2010_7_precip, mada_2010_8_precip, mada_2010_9_precip, mada_2010_10_precip, mada_2010_11_precip, mada_2010_12_precip)
mada_2010_precip$Year <- 2010

mada_2011_precip <- rbind(mada_2011_1_precip, mada_2011_2_precip, mada_2011_3_precip, mada_2011_4_precip, mada_2011_5_precip, mada_2011_6_precip, mada_2011_7_precip, mada_2011_8_precip, mada_2011_9_precip, mada_2011_10_precip, mada_2011_11_precip, mada_2011_12_precip)
mada_2011_precip$Year <- 2011

mada_2012_precip <- rbind(mada_2012_1_precip, mada_2012_2_precip, mada_2012_3_precip, mada_2012_4_precip, mada_2012_5_precip, mada_2012_6_precip, mada_2012_7_precip, mada_2012_8_precip, mada_2012_9_precip, mada_2012_10_precip, mada_2012_11_precip, mada_2012_12_precip)
mada_2012_precip$Year <- 2012

mada_2013_precip <- rbind(mada_2013_1_precip, mada_2013_2_precip, mada_2013_3_precip, mada_2013_4_precip, mada_2013_5_precip, mada_2013_6_precip, mada_2013_7_precip, mada_2013_8_precip, mada_2013_9_precip, mada_2013_10_precip, mada_2013_11_precip, mada_2013_12_precip)
mada_2013_precip$Year <- 2013

mada_2014_precip <- rbind(mada_2014_1_precip, mada_2014_2_precip, mada_2014_3_precip, mada_2014_4_precip, mada_2014_5_precip, mada_2014_6_precip, mada_2014_7_precip, mada_2014_8_precip, mada_2014_9_precip, mada_2014_10_precip, mada_2014_11_precip, mada_2014_12_precip)
mada_2014_precip$Year <- 2014

mada_2015_precip <- rbind(mada_2015_1_precip, mada_2015_2_precip, mada_2015_3_precip, mada_2015_4_precip, mada_2015_5_precip, mada_2015_6_precip, mada_2015_7_precip, mada_2015_8_precip, mada_2015_9_precip, mada_2015_10_precip, mada_2015_11_precip, mada_2015_12_precip)
mada_2015_precip$Year <- 2015

mada_2016_precip <- rbind(mada_2016_1_precip, mada_2016_2_precip, mada_2016_3_precip, mada_2016_4_precip, mada_2016_5_precip, mada_2016_6_precip, mada_2016_7_precip, mada_2016_8_precip, mada_2016_9_precip, mada_2016_10_precip, mada_2016_11_precip)
mada_2016_precip$Year <- 2016

mada_2017_precip <- rbind(mada_2017_1_precip, mada_2017_2_precip, mada_2017_3_precip, mada_2017_4_precip, mada_2017_5_precip, mada_2017_6_precip, mada_2017_7_precip, mada_2017_8_precip, mada_2017_9_precip, mada_2017_10_precip, mada_2017_11_precip, mada_2017_12_precip)
mada_2017_precip$Year <- 2017

mada_2018_precip <- rbind(mada_2018_1_precip, mada_2018_2_precip, mada_2018_3_precip, mada_2018_4_precip, mada_2018_5_precip, mada_2018_6_precip, mada_2018_7_precip, mada_2018_8_precip, mada_2018_9_precip, mada_2018_10_precip, mada_2018_11_precip, mada_2018_12_precip)
mada_2018_precip$Year <- 2018

mada_2019_precip <- rbind(mada_2019_1_precip, mada_2019_2_precip, mada_2019_3_precip, mada_2019_4_precip, mada_2019_5_precip, mada_2019_6_precip, mada_2019_7_precip, mada_2019_8_precip, mada_2019_9_precip, mada_2019_10_precip, mada_2019_11_precip, mada_2019_12_precip)
mada_2019_precip$Year <- 2019

mada_2020_precip <- rbind(mada_2020_1_precip, mada_2020_2_precip, mada_2020_3_precip, mada_2020_4_precip, mada_2020_5_precip, mada_2020_6_precip, mada_2020_7_precip, mada_2020_8_precip, mada_2020_9_precip, mada_2020_10_precip, mada_2020_11_precip, mada_2020_12_precip)
mada_2020_precip$Year <- 2020

mada_2021_precip <- rbind(mada_2021_1_precip, mada_2021_2_precip, mada_2021_3_precip, mada_2021_4_precip, mada_2021_5_precip, mada_2021_6_precip, mada_2021_7_precip, mada_2021_8_precip, mada_2021_9_precip, mada_2021_10_precip, mada_2021_11_precip, mada_2021_12_precip)
mada_2021_precip$Year <- 2021

###COMBINE ALL YEARS INTO ONE DATA FRAME
mada_precip <- rbind(mada_2000_precip, mada_2001_precip, mada_2002_precip, mada_2003_precip, mada_2004_precip, mada_2005_precip, mada_2006_precip, mada_2007_precip, mada_2008_precip, mada_2009_precip, mada_2010_precip, mada_2011_precip, mada_2012_precip, mada_2013_precip, mada_2014_precip, mada_2015_precip, mada_2016_precip, mada_2017_precip,mada_2018_precip)
mada_precip <- mada_precip %>% dplyr::select(OBJECTID, NOM, ZONE_CODE, COUNT, MEAN, Year)
mada_2019_precip <- mada_2019_precip  %>% dplyr::select(OBJECTID, NOM, ZONE_CODE, COUNT, MEAN, Year)
mada_2020_precip <- mada_2020_precip  %>% dplyr::select(OBJECTID, NOM, ZONE_CODE, COUNT, MEAN, Year)
mada_2021_precip <- mada_2021_precip  %>% dplyr::select(OBJECTID, NOM, ZONE_CODE, COUNT, MEAN, Year)
mada_precip <- rbind(mada_precip, mada_2019_precip, mada_2020_precip, mada_2021_precip)

mada_precip <- left_join(mada_precip, area_dat, by="NOM")

#select variables relevant for analysis
mada_precip2 <- mada_precip %>% dplyr::select(NOM, MEAN, Year, AREA) %>%drop_na()%>% group_by(Year, NOM) %>% dplyr::summarise(precipitation = mean(MEAN), area=mean(AREA)) %>% dplyr::rename(Name=NOM)
#check for missing clues 
mada_precip2[is.na(mada_precip2$precipitation),]
#no missing precipitation values 

#combine Analamazaotra and Mantadia into one Park 
mada_precip2$Name[mada_precip2$Name=="Analamazaotra"]<- "Andasibe/Analamazaotra"
mada_precip2$Name[mada_precip2$Name=="Mantadia"]<- "Andasibe/Analamazaotra"
#combine Bemaraha north and south into one Park
mada_precip2$Name[mada_precip2$Name=="Bemaraha (partie Nord)"]<- "Bemaraha (combined)"
mada_precip2$Name[mada_precip2$Name=="Bemaraha partie Sud"]<- "Bemaraha (combined)"
#combine Namoroka and Baie de Baly into one Park
mada_precip2$Name[mada_precip2$Name=="Tsingy de Namoroka"]<- "Namoroka/Baie de Baly"
mada_precip2$Name[mada_precip2$Name=="Baie de Baly"]<- "Namoroka/Baie de Baly"
#combine zahamena
mada_precip2$Name[mada_precip2$Name=="Zahamena RNI"]<-  "Zahamena" 
mada_precip2$Name[mada_precip2$Name=="Foret d'Ambre"]<-  "Montagne d'Ambre" 
mada_precip2$Name[mada_precip2$Name=="Nosy Mangabe" ]<- "Masoala"


mada_precip2 <- mada_precip2 %>% group_by(Year, Name) %>% dplyr::summarise(precipitation_old = mean(precipitation*area), area=mean(area), precipitation =precipitation_old/area)%>% dplyr::select(Year, Name, precipitation)


write.csv(mada_precip2, "~/Documents/GitHub/TourismDeforestation/Data/CleanedConfounders/precipitation2.csv")


```

```{r Precipitation Compilation-- Commune}
###IMPORT   MONTHLY PRECIPITATION DATA
#2000
mada_2000_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2000_01CommuneNew.xls")
mada_2000_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2000_02CommuneNew.xls")
mada_2000_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2000_03CommuneNew.xls")
mada_2000_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2000_04CommuneNew.xls")
mada_2000_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2000_05CommuneNew.xls")
mada_2000_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2000_06CommuneNew.xls")
mada_2000_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2000_07CommuneNew.xls")
mada_2000_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2000_08CommuneNew.xls")
mada_2000_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2000_09CommuneNew.xls")
mada_2000_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2000_10CommuneNew.xls")
mada_2000_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2000_11CommuneNew.xls")
mada_2000_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2000_12CommuneNew.xls")
#2001
mada_2001_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2001_01CommuneNew.xls")
mada_2001_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2001_02CommuneNew.xls")
mada_2001_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2001_03CommuneNew.xls")
mada_2001_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2001_04CommuneNew.xls")
mada_2001_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2001_05CommuneNew.xls")
mada_2001_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2001_06CommuneNew.xls")
mada_2001_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2001_07CommuneNew.xls")
mada_2001_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2001_08CommuneNew.xls")
mada_2001_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2001_09CommuneNew.xls")
mada_2001_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2001_10CommuneNew.xls")
mada_2001_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2001_11CommuneNew.xls")
mada_2001_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2001_12CommuneNew.xls")
#2002
mada_2002_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2002_01CommuneNew.xls")
mada_2002_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2002_02CommuneNew.xls")
mada_2002_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2002_03CommuneNew.xls")
mada_2002_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2002_04CommuneNew.xls")
mada_2002_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2002_05CommuneNew.xls")
mada_2002_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2002_06CommuneNew.xls")
mada_2002_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2002_07CommuneNew.xls")
mada_2002_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2002_08CommuneNew.xls")
mada_2002_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2002_09CommuneNew.xls")
mada_2002_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2002_10CommuneNew.xls")
mada_2002_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2002_11CommuneNew.xls")
mada_2002_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2002_12CommuneNew.xls")
#2003
mada_2003_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2003_01CommuneNew.xls")
mada_2003_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2003_02CommuneNew.xls")
mada_2003_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2003_03CommuneNew.xls")
mada_2003_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2003_04CommuneNew.xls")
mada_2003_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2003_05CommuneNew.xls")
mada_2003_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2003_06CommuneNew.xls")
mada_2003_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2003_07CommuneNew.xls")
mada_2003_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2003_08CommuneNew.xls")
mada_2003_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2003_09CommuneNew.xls")
mada_2003_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2003_10CommuneNew.xls")
mada_2003_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2003_11CommuneNew.xls")
mada_2003_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2003_12CommuneNew.xls")
#2004
mada_2004_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2004_01CommuneNew.xls")
mada_2004_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2004_02CommuneNew.xls")
mada_2004_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2004_03CommuneNew.xls")
mada_2004_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2004_04CommuneNew.xls")
mada_2004_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2004_05CommuneNew.xls")
mada_2004_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2004_06CommuneNew.xls")
mada_2004_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2004_07CommuneNew.xls")
mada_2004_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2004_08CommuneNew.xls")
mada_2004_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2004_09CommuneNew.xls")
mada_2004_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2004_10CommuneNew.xls")
mada_2004_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2004_11CommuneNew.xls")
mada_2004_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2004_12CommuneNew.xls")
#2005
mada_2005_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2005_01CommuneNew.xls")
mada_2005_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2005_02CommuneNew.xls")
mada_2005_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2005_03CommuneNew.xls")
mada_2005_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2005_04CommuneNew.xls")
mada_2005_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2005_05CommuneNew.xls")
mada_2005_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2005_06CommuneNew.xls")
mada_2005_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2005_07CommuneNew.xls")
mada_2005_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2005_08CommuneNew.xls")
mada_2005_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2005_09CommuneNew.xls")
mada_2005_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2005_10CommuneNew.xls")
mada_2005_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2005_11CommuneNew.xls")
mada_2005_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2005_12CommuneNew.xls")
#2006
mada_2006_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2006_01CommuneNew.xls")
mada_2006_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2006_02CommuneNew.xls")
mada_2006_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2006_03CommuneNew.xls")
mada_2006_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2006_04CommuneNew.xls")
mada_2006_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2006_05CommuneNew.xls")
mada_2006_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2006_06CommuneNew.xls")
mada_2006_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2006_07CommuneNew.xls")
mada_2006_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2006_08CommuneNew.xls")
mada_2006_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2006_09CommuneNew.xls")
mada_2006_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2006_10CommuneNew.xls")
mada_2006_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2006_11CommuneNew.xls")
mada_2006_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2006_12CommuneNew.xls")
#2007
mada_2007_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2007_01CommuneNew.xls")
mada_2007_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2007_02CommuneNew.xls")
mada_2007_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2007_03CommuneNew.xls")
mada_2007_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2007_04CommuneNew.xls")
mada_2007_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2007_05CommuneNew.xls")
mada_2007_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2007_06CommuneNew.xls")
mada_2007_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2007_07CommuneNew.xls")
mada_2007_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2007_08CommuneNew.xls")
mada_2007_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2007_09CommuneNew.xls")
mada_2007_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2007_10CommuneNew.xls")
mada_2007_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2007_11CommuneNew.xls")
mada_2007_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2007_12CommuneNew.xls")
#2008
mada_2008_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2008_01CommuneNew.xls")
mada_2008_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2008_02CommuneNew.xls")
mada_2008_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2008_03CommuneNew.xls")
mada_2008_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2008_04CommuneNew.xls")
mada_2008_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2008_05CommuneNew.xls")
mada_2008_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2008_06CommuneNew.xls")
mada_2008_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2008_07CommuneNew.xls")
mada_2008_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2008_08CommuneNew.xls")
mada_2008_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2008_09CommuneNew.xls")
mada_2008_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2008_10CommuneNew.xls")
mada_2008_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2008_11CommuneNew.xls")
mada_2008_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2008_12CommuneNew.xls")
#2009
mada_2009_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2009_01CommuneNew.xls")
mada_2009_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2009_02CommuneNew.xls")
mada_2009_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2009_03CommuneNew.xls")
mada_2009_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2009_04CommuneNew.xls")
mada_2009_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2009_05CommuneNew.xls")
mada_2009_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2009_06CommuneNew.xls")
mada_2009_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2009_07CommuneNew.xls")
mada_2009_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2009_08CommuneNew.xls")
mada_2009_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2009_09CommuneNew.xls")
mada_2009_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2009_10CommuneNew.xls")
mada_2009_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2009_11CommuneNew.xls")
mada_2009_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2009_12CommuneNew.xls")
#2010
mada_2010_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2010_01CommuneNew.xls")
mada_2010_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2010_02CommuneNew.xls")
mada_2010_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2010_03CommuneNew.xls")
mada_2010_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2010_04CommuneNew.xls")
mada_2010_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2010_05CommuneNew.xls")
mada_2010_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2010_06CommuneNew.xls")
mada_2010_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2010_07CommuneNew.xls")
mada_2010_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2010_08CommuneNew.xls")
mada_2010_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2010_09CommuneNew.xls")
mada_2010_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2010_10CommuneNew.xls")
mada_2010_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2010_11CommuneNew.xls")
mada_2010_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2010_12CommuneNew.xls")
#2011
mada_2011_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2011_01CommuneNew.xls")
mada_2011_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2011_02CommuneNew.xls")
mada_2011_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2011_03CommuneNew.xls")
mada_2011_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2011_04CommuneNew.xls")
mada_2011_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2011_05CommuneNew.xls")
mada_2011_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2011_06CommuneNew.xls")
mada_2011_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2011_07CommuneNew.xls")
mada_2011_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2011_08CommuneNew.xls")
mada_2011_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2011_09CommuneNew.xls")
mada_2011_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2011_10CommuneNew.xls")
mada_2011_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2011_11CommuneNew.xls")
mada_2011_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2011_12CommuneNew.xls")
#2012
mada_2012_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2012_01CommuneNew.xls")
mada_2012_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2012_02CommuneNew.xls")
mada_2012_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2012_03CommuneNew.xls")
mada_2012_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2012_04CommuneNew.xls")
mada_2012_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2012_05CommuneNew.xls")
mada_2012_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2012_06CommuneNew.xls")
mada_2012_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2012_07CommuneNew.xls")
mada_2012_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2012_08CommuneNew.xls")
mada_2012_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2012_09CommuneNew.xls")
mada_2012_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2012_10CommuneNew.xls")
mada_2012_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2012_11CommuneNew.xls")
mada_2012_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2012_12CommuneNew.xls")
#2013
mada_2013_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2013_01CommuneNew.xls")
mada_2013_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2013_02CommuneNew.xls")
mada_2013_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2013_03CommuneNew.xls")
mada_2013_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2013_04CommuneNew.xls")
mada_2013_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2013_05CommuneNew.xls")
mada_2013_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2013_06CommuneNew.xls")
mada_2013_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2013_07CommuneNew.xls")
mada_2013_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2013_08CommuneNew.xls")
mada_2013_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2013_09CommuneNew.xls")
mada_2013_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2013_10CommuneNew.xls")
mada_2013_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2013_11CommuneNew.xls")
mada_2013_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2013_12CommuneNew.xls")
#2014
mada_2014_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2014_01CommuneNew.xls")
mada_2014_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2014_02CommuneNew.xls")
mada_2014_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2014_03CommuneNew.xls")
mada_2014_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2014_04CommuneNew.xls")
mada_2014_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2014_05CommuneNew.xls")
mada_2014_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2014_06CommuneNew.xls")
mada_2014_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2014_07CommuneNew.xls")
mada_2014_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2014_08CommuneNew.xls")
mada_2014_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2014_09CommuneNew.xls")
mada_2014_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2014_10CommuneNew.xls")
mada_2014_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2014_11CommuneNew.xls")
mada_2014_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2014_12CommuneNew.xls")
#2015
mada_2015_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2015_01CommuneNew.xls")
mada_2015_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2015_02CommuneNew.xls")
mada_2015_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2015_03CommuneNew.xls")
mada_2015_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2015_04CommuneNew.xls")
mada_2015_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2015_05CommuneNew.xls")
mada_2015_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2015_06CommuneNew.xls")
mada_2015_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2015_07CommuneNew.xls")
mada_2015_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2015_08CommuneNew.xls")
mada_2015_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2015_09CommuneNew.xls")
mada_2015_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2015_10CommuneNew.xls")
mada_2015_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2015_11CommuneNew.xls")
mada_2015_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2015_12CommuneNew.xls")
#2016
mada_2016_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2016_01CommuneNew.xls")
mada_2016_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2016_02CommuneNew.xls")
mada_2016_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2016_03CommuneNew.xls")
mada_2016_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2016_04CommuneNew.xls")
mada_2016_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2016_05CommuneNew.xls")
mada_2016_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2016_06CommuneNew.xls")
mada_2016_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2016_07CommuneNew.xls")
mada_2016_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2016_08CommuneNew.xls")
mada_2016_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2016_09CommuneNew.xls")
mada_2016_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2016_10CommuneNew.xls")
mada_2016_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2016_11CommuneNew.xls")
mada_2016_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2016_12CommuneNew.xls")
#2017
mada_2017_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2017_01CommuneNew.xls")
mada_2017_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2017_02CommuneNew.xls")
mada_2017_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2017_03CommuneNew.xls")
mada_2017_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2017_04CommuneNew.xls")
mada_2017_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2017_05CommuneNew.xls")
mada_2017_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2017_06CommuneNew.xls")
mada_2017_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2017_07CommuneNew.xls")
mada_2017_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2017_08CommuneNew.xls")
mada_2017_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2017_09CommuneNew.xls")
mada_2017_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2017_10CommuneNew.xls")
mada_2017_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2017_11CommuneNew.xls")
mada_2017_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2017_12CommuneNew.xls")
#2018
mada_2018_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2018_01CommuneNew.xls")
mada_2018_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2018_02CommuneNew.xls")
mada_2018_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2018_03CommuneNew.xls")
mada_2018_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2018_04CommuneNew.xls")
mada_2018_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2018_05CommuneNew.xls")
mada_2018_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2018_06CommuneNew.xls")
mada_2018_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2018_07CommuneNew.xls")
mada_2018_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2018_08CommuneNew.xls")
mada_2018_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2018_09CommuneNew.xls")
mada_2018_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2018_10CommuneNew.xls")
mada_2018_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2018_11CommuneNew.xls")
mada_2018_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2018_12CommuneNew.xls")
#2019
mada_2019_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-01CommuneNew.xls")
mada_2019_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-02CommuneNew.xls")
mada_2019_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-03CommuneNew.xls")
mada_2019_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-04CommuneNew.xls")
mada_2019_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-05CommuneNew.xls")
mada_2019_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-06CommuneNew.xls")
mada_2019_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-07CommuneNew.xls")
mada_2019_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-08CommuneNew.xls")
mada_2019_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-09CommuneNew.xls")
mada_2019_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-10CommuneNew.xls")
mada_2019_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-11CommuneNew.xls")
mada_2019_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2019-12CommuneNew.xls")
#2020
mada_2020_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-01CommuneNew.xls")
mada_2020_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-02CommuneNew.xls")
mada_2020_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-03CommuneNew.xls")
mada_2020_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-04CommuneNew.xls")
mada_2020_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-05CommuneNew.xls")
mada_2020_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-06CommuneNew.xls")
mada_2020_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-07CommuneNew.xls")
mada_2020_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-08CommuneNew.xls")
mada_2020_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-09CommuneNew.xls")
mada_2020_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-10CommuneNew.xls")
mada_2020_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-11CommuneNew.xls")
mada_2020_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2020-12CommuneNew.xls")
#2021
mada_2021_1_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-01CommuneNew.xls")
mada_2021_2_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-02CommuneNew.xls")
mada_2021_3_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-03CommuneNew.xls")
mada_2021_4_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-04CommuneNew.xls")
mada_2021_5_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-05CommuneNew.xls")
mada_2021_6_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-06CommuneNew.xls")
mada_2021_7_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-07CommuneNew.xls")
mada_2021_8_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-08CommuneNew.xls")
mada_2021_9_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-09CommuneNew.xls")
mada_2021_10_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-10CommuneNew.xls")
mada_2021_11_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-11CommuneNew.xls")
mada_2021_12_precip_CommuneNew <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/PrecPoints_prec_2021-12CommuneNew.xls")

###COMPILE MONTHLY PRECIPITATION DATA BY YEAR 
mada_2000_precip_CommuneNew <- rbind(mada_2000_1_precip_CommuneNew, mada_2000_2_precip_CommuneNew, mada_2000_3_precip_CommuneNew, mada_2000_4_precip_CommuneNew, mada_2000_5_precip_CommuneNew, mada_2000_6_precip_CommuneNew, mada_2000_7_precip_CommuneNew, mada_2000_8_precip_CommuneNew, mada_2000_9_precip_CommuneNew, mada_2000_10_precip_CommuneNew, mada_2000_11_precip_CommuneNew, mada_2000_12_precip_CommuneNew)
mada_2000_precip_CommuneNew$Year <- 2000


mada_2001_precip_CommuneNew <- rbind(mada_2001_1_precip_CommuneNew, mada_2001_2_precip_CommuneNew, mada_2001_3_precip_CommuneNew, mada_2001_4_precip_CommuneNew, mada_2001_5_precip_CommuneNew, mada_2001_6_precip_CommuneNew, mada_2001_7_precip_CommuneNew, mada_2001_8_precip_CommuneNew, mada_2001_9_precip_CommuneNew, mada_2001_10_precip_CommuneNew, mada_2001_11_precip_CommuneNew, mada_2001_12_precip_CommuneNew)
mada_2001_precip_CommuneNew$Year <- 2001

mada_2002_precip_CommuneNew <- rbind(mada_2002_1_precip_CommuneNew, mada_2002_2_precip_CommuneNew, mada_2002_3_precip_CommuneNew, mada_2002_4_precip_CommuneNew, mada_2002_5_precip_CommuneNew, mada_2002_6_precip_CommuneNew, mada_2002_7_precip_CommuneNew, mada_2002_8_precip_CommuneNew, mada_2002_9_precip_CommuneNew, mada_2002_10_precip_CommuneNew, mada_2002_11_precip_CommuneNew, mada_2002_12_precip_CommuneNew)
mada_2002_precip_CommuneNew$Year <- 2002

mada_2003_precip_CommuneNew <- rbind(mada_2003_1_precip_CommuneNew, mada_2003_2_precip_CommuneNew, mada_2003_3_precip_CommuneNew, mada_2003_4_precip_CommuneNew, mada_2003_5_precip_CommuneNew, mada_2003_6_precip_CommuneNew, mada_2003_7_precip_CommuneNew, mada_2003_8_precip_CommuneNew, mada_2003_9_precip_CommuneNew, mada_2003_10_precip_CommuneNew, mada_2003_11_precip_CommuneNew, mada_2003_12_precip_CommuneNew)
mada_2003_precip_CommuneNew$Year <- 2003

mada_2004_precip_CommuneNew <- rbind(mada_2004_1_precip_CommuneNew, mada_2004_2_precip_CommuneNew, mada_2004_3_precip_CommuneNew, mada_2004_4_precip_CommuneNew,  mada_2004_5_precip_CommuneNew, mada_2004_6_precip_CommuneNew, mada_2004_7_precip_CommuneNew, mada_2004_8_precip_CommuneNew, mada_2004_9_precip_CommuneNew, mada_2004_10_precip_CommuneNew, mada_2004_11_precip_CommuneNew, mada_2004_12_precip_CommuneNew)
mada_2004_precip_CommuneNew$Year <- 2004

mada_2005_precip_CommuneNew <- rbind(mada_2005_1_precip_CommuneNew, mada_2005_2_precip_CommuneNew, mada_2005_3_precip_CommuneNew, mada_2005_4_precip_CommuneNew, mada_2005_5_precip_CommuneNew, mada_2005_6_precip_CommuneNew, mada_2005_7_precip_CommuneNew, mada_2005_8_precip_CommuneNew, mada_2005_9_precip_CommuneNew, mada_2005_10_precip_CommuneNew, mada_2005_11_precip_CommuneNew, mada_2005_12_precip_CommuneNew)
mada_2005_precip_CommuneNew$Year <- 2005

mada_2006_precip_CommuneNew <- rbind(mada_2006_1_precip_CommuneNew, mada_2006_2_precip_CommuneNew, mada_2006_3_precip_CommuneNew, mada_2006_4_precip_CommuneNew, mada_2006_5_precip_CommuneNew, mada_2006_6_precip_CommuneNew, mada_2006_7_precip_CommuneNew, mada_2006_8_precip_CommuneNew, mada_2006_9_precip_CommuneNew, mada_2006_10_precip_CommuneNew, mada_2006_11_precip_CommuneNew, mada_2006_12_precip_CommuneNew)
mada_2006_precip_CommuneNew$Year <- 2006

mada_2007_precip_CommuneNew <- rbind(mada_2007_1_precip_CommuneNew, mada_2007_2_precip_CommuneNew, mada_2007_3_precip_CommuneNew, mada_2007_4_precip_CommuneNew, mada_2007_5_precip_CommuneNew, mada_2007_6_precip_CommuneNew, mada_2007_8_precip_CommuneNew, mada_2007_9_precip_CommuneNew, mada_2007_10_precip_CommuneNew, mada_2007_11_precip_CommuneNew, mada_2007_12_precip_CommuneNew)
mada_2007_precip_CommuneNew$Year <- 2007

mada_2008_precip_CommuneNew <- rbind(mada_2008_1_precip_CommuneNew, mada_2008_2_precip_CommuneNew, mada_2008_3_precip_CommuneNew, mada_2008_4_precip_CommuneNew, mada_2008_5_precip_CommuneNew, mada_2008_6_precip_CommuneNew, mada_2008_7_precip_CommuneNew, mada_2008_8_precip_CommuneNew, mada_2008_9_precip_CommuneNew, mada_2008_10_precip_CommuneNew, mada_2008_11_precip_CommuneNew, mada_2008_12_precip_CommuneNew)
mada_2008_precip_CommuneNew$Year <- 2008

mada_2009_precip_CommuneNew <- rbind(mada_2009_1_precip_CommuneNew, mada_2009_2_precip_CommuneNew, mada_2009_3_precip_CommuneNew, mada_2009_4_precip_CommuneNew, mada_2009_5_precip_CommuneNew, mada_2009_6_precip_CommuneNew, mada_2009_7_precip_CommuneNew, mada_2009_8_precip_CommuneNew, mada_2009_9_precip_CommuneNew, mada_2009_10_precip_CommuneNew, mada_2009_11_precip_CommuneNew, mada_2009_12_precip_CommuneNew)
mada_2009_precip_CommuneNew$Year <- 2009

mada_2010_precip_CommuneNew <- rbind(mada_2010_1_precip_CommuneNew, mada_2010_2_precip_CommuneNew, mada_2010_3_precip_CommuneNew, mada_2010_4_precip_CommuneNew, mada_2010_5_precip_CommuneNew, mada_2010_6_precip_CommuneNew, mada_2010_7_precip_CommuneNew, mada_2010_8_precip_CommuneNew, mada_2010_9_precip_CommuneNew, mada_2010_10_precip_CommuneNew, mada_2010_11_precip_CommuneNew, mada_2010_12_precip_CommuneNew)
mada_2010_precip_CommuneNew$Year <- 2010

mada_2011_precip_CommuneNew <- rbind(mada_2011_1_precip_CommuneNew, mada_2011_2_precip_CommuneNew, mada_2011_3_precip_CommuneNew, mada_2011_4_precip_CommuneNew, mada_2011_5_precip_CommuneNew, mada_2011_6_precip_CommuneNew, mada_2011_7_precip_CommuneNew, mada_2011_8_precip_CommuneNew, mada_2011_9_precip_CommuneNew, mada_2011_10_precip_CommuneNew, mada_2011_11_precip_CommuneNew, mada_2011_12_precip_CommuneNew)
mada_2011_precip_CommuneNew$Year <- 2011

mada_2012_precip_CommuneNew <- rbind(mada_2012_1_precip_CommuneNew, mada_2012_2_precip_CommuneNew, mada_2012_3_precip_CommuneNew, mada_2012_4_precip_CommuneNew, mada_2012_5_precip_CommuneNew, mada_2012_6_precip_CommuneNew, mada_2012_7_precip_CommuneNew, mada_2012_8_precip_CommuneNew, mada_2012_9_precip_CommuneNew, mada_2012_10_precip_CommuneNew, mada_2012_11_precip_CommuneNew, mada_2012_12_precip_CommuneNew)
mada_2012_precip_CommuneNew$Year <- 2012

mada_2013_precip_CommuneNew <- rbind(mada_2013_1_precip_CommuneNew, mada_2013_2_precip_CommuneNew, mada_2013_3_precip_CommuneNew, mada_2013_4_precip_CommuneNew, mada_2013_5_precip_CommuneNew, mada_2013_6_precip_CommuneNew, mada_2013_7_precip_CommuneNew, mada_2013_8_precip_CommuneNew, mada_2013_9_precip_CommuneNew, mada_2013_10_precip_CommuneNew, mada_2013_11_precip_CommuneNew, mada_2013_12_precip_CommuneNew)
mada_2013_precip_CommuneNew$Year <- 2013

mada_2014_precip_CommuneNew <- rbind(mada_2014_1_precip_CommuneNew, mada_2014_2_precip_CommuneNew, mada_2014_3_precip_CommuneNew, mada_2014_4_precip_CommuneNew, mada_2014_5_precip_CommuneNew, mada_2014_6_precip_CommuneNew, mada_2014_7_precip_CommuneNew, mada_2014_8_precip_CommuneNew, mada_2014_9_precip_CommuneNew, mada_2014_10_precip_CommuneNew, mada_2014_11_precip_CommuneNew, mada_2014_12_precip_CommuneNew)
mada_2014_precip_CommuneNew$Year <- 2014

mada_2015_precip_CommuneNew <- rbind(mada_2015_1_precip_CommuneNew, mada_2015_2_precip_CommuneNew, mada_2015_3_precip_CommuneNew, mada_2015_4_precip_CommuneNew, mada_2015_5_precip_CommuneNew, mada_2015_6_precip_CommuneNew, mada_2015_7_precip_CommuneNew, mada_2015_8_precip_CommuneNew, mada_2015_9_precip_CommuneNew, mada_2015_10_precip_CommuneNew, mada_2015_11_precip_CommuneNew, mada_2015_12_precip_CommuneNew)
mada_2015_precip_CommuneNew$Year <- 2015

mada_2016_precip_CommuneNew <- rbind(mada_2016_1_precip_CommuneNew, mada_2016_2_precip_CommuneNew, mada_2016_3_precip_CommuneNew, mada_2016_4_precip_CommuneNew, mada_2016_5_precip_CommuneNew, mada_2016_6_precip_CommuneNew, mada_2016_7_precip_CommuneNew, mada_2016_8_precip_CommuneNew, mada_2016_9_precip_CommuneNew, mada_2016_10_precip_CommuneNew, mada_2016_11_precip_CommuneNew)
mada_2016_precip_CommuneNew$Year <- 2016

mada_2017_precip_CommuneNew <- rbind(mada_2017_1_precip_CommuneNew, mada_2017_2_precip_CommuneNew, mada_2017_3_precip_CommuneNew, mada_2017_4_precip_CommuneNew, mada_2017_5_precip_CommuneNew, mada_2017_6_precip_CommuneNew, mada_2017_7_precip_CommuneNew, mada_2017_8_precip_CommuneNew, mada_2017_9_precip_CommuneNew, mada_2017_10_precip_CommuneNew, mada_2017_11_precip_CommuneNew, mada_2017_12_precip_CommuneNew)
mada_2017_precip_CommuneNew$Year <- 2017

mada_2018_precip_CommuneNew <- rbind(mada_2018_1_precip_CommuneNew, mada_2018_2_precip_CommuneNew, mada_2018_3_precip_CommuneNew, mada_2018_4_precip_CommuneNew, mada_2018_5_precip_CommuneNew, mada_2018_6_precip_CommuneNew, mada_2018_7_precip_CommuneNew, mada_2018_8_precip_CommuneNew, mada_2018_9_precip_CommuneNew, mada_2018_10_precip_CommuneNew, mada_2018_11_precip_CommuneNew, mada_2018_12_precip_CommuneNew)
mada_2018_precip_CommuneNew$Year <- 2018

mada_2019_precip_CommuneNew <- rbind(mada_2019_1_precip_CommuneNew, mada_2019_2_precip_CommuneNew, mada_2019_3_precip_CommuneNew, mada_2019_4_precip_CommuneNew, mada_2019_5_precip_CommuneNew, mada_2019_6_precip_CommuneNew, mada_2019_7_precip_CommuneNew, mada_2019_8_precip_CommuneNew, mada_2019_9_precip_CommuneNew, mada_2019_10_precip_CommuneNew, mada_2019_11_precip_CommuneNew, mada_2019_12_precip_CommuneNew)
mada_2019_precip_CommuneNew$Year <- 2019

mada_2020_precip_CommuneNew <- rbind(mada_2020_1_precip_CommuneNew, mada_2020_2_precip_CommuneNew, mada_2020_3_precip_CommuneNew, mada_2020_4_precip_CommuneNew, mada_2020_5_precip_CommuneNew, mada_2020_6_precip_CommuneNew, mada_2020_7_precip_CommuneNew, mada_2020_8_precip_CommuneNew, mada_2020_9_precip_CommuneNew, mada_2020_10_precip_CommuneNew, mada_2020_11_precip_CommuneNew, mada_2020_12_precip_CommuneNew)
mada_2020_precip_CommuneNew$Year <- 2020

mada_2021_precip_CommuneNew <- rbind(mada_2021_1_precip_CommuneNew, mada_2021_2_precip_CommuneNew, mada_2021_3_precip_CommuneNew, mada_2021_4_precip_CommuneNew, mada_2021_5_precip_CommuneNew, mada_2021_6_precip_CommuneNew, mada_2021_7_precip_CommuneNew, mada_2021_8_precip_CommuneNew, mada_2021_9_precip_CommuneNew, mada_2021_10_precip_CommuneNew, mada_2021_11_precip_CommuneNew, mada_2021_12_precip_CommuneNew)
mada_2021_precip_CommuneNew$Year <- 2021

###COMBINE ALL YEARS INTO ONE DATA FRAME
mada_precip_commune <- rbind(mada_2000_precip_CommuneNew, mada_2001_precip_CommuneNew, mada_2002_precip_CommuneNew, mada_2003_precip_CommuneNew, mada_2004_precip_CommuneNew, mada_2005_precip_CommuneNew, mada_2006_precip_CommuneNew, mada_2007_precip_CommuneNew, mada_2008_precip_CommuneNew, mada_2009_precip_CommuneNew, mada_2010_precip_CommuneNew, mada_2011_precip_CommuneNew, mada_2012_precip_CommuneNew, mada_2013_precip_CommuneNew, mada_2014_precip_CommuneNew, mada_2015_precip_CommuneNew, mada_2016_precip_CommuneNew, mada_2017_precip_CommuneNew,mada_2018_precip_CommuneNew, mada_2019_precip_CommuneNew, mada_2020_precip_CommuneNew, mada_2021_precip_CommuneNew)

mada_precip_commune <- mada_precip_commune %>% select(OBJECTID, NOM, COUNT, MEAN, Year)
mada_precip_commune <- left_join(mada_precip_commune, area_dat_commune, by="NOM")

#select variables relevant for analysis
mada_precip_commune2 <- mada_precip_commune%>% dplyr::select(NOM, MEAN, Year, AREA) %>%drop_na()%>% group_by(Year, NOM) %>% dplyr::summarise(precipitation = mean(MEAN), area=mean(AREA)) %>% dplyr::rename(Name=NOM)
#check for missing clues 
mada_precip_commune2[is.na(mada_precip_commune2$precipitation),]
#no missing precipitation values 

#combine Analamazaotra and Mantadia into one Park 
mada_precip_commune2$Name[mada_precip_commune2$Name=="Analamazaotra"]<- "Andasibe/Analamazaotra"
mada_precip_commune2$Name[mada_precip_commune2$Name=="Mantadia"]<- "Andasibe/Analamazaotra"
#combine Bemaraha north and south into one Park
mada_precip_commune2$Name[mada_precip_commune2$Name=="Bemaraha (partie Nord)"]<- "Bemaraha (combined)"
mada_precip_commune2$Name[mada_precip_commune2$Name=="Bemaraha partie Sud"]<- "Bemaraha (combined)"
#combine Namoroka and Baie de Baly into one Park
mada_precip_commune2$Name[mada_precip_commune2$Name=="Tsingy de Namoroka"]<- "Namoroka/Baie de Baly"
mada_precip_commune2$Name[mada_precip_commune2$Name=="Baie de Baly"]<- "Namoroka/Baie de Baly"
#combine zahamena
mada_precip_commune2$Name[mada_precip_commune2$Name=="Zahamena RNI"]<-  "Zahamena" 
mada_precip_commune2$Name[mada_precip_commune2$Name=="Foret d'Ambre"]<-  "Montagne d'Ambre" 
mada_precip_commune2$Name[mada_precip_commune2$Name=="Nosy Mangabe" ]<- "Masoala"

mada_precip_commune2 <- mada_precip_commune2 %>% group_by(Year, Name) %>% dplyr::summarise(precipitation_old = mean(precipitation*area), area=mean(area), precipitation =precipitation_old/area) %>% dplyr::select(Year, Name, precipitation)


write.csv(mada_precip_commune2, "~/Documents/GitHub/TourismDeforestation/Data/CleanedConfounders/precipitation_commune.csv")

```

```{r Population Density Compulation -- Full }
#IMPORT POPULATION DENSITY DATA
PopDensity1990  <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/poppark1990_zonal_TableToExcel.xlsx")
PopDensity2000 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2000_1km_UNadj.xlsx")
PopDensity2001 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2001_1km_UNadj.xlsx")
PopDensity2002 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2002_1km_UNadj.xlsx")
PopDensity2003 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2003_1km_UNadj.xlsx")
PopDensity2004 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2004_1km_UNadj.xlsx")
PopDensity2005 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2005_1km_UNadj.xlsx")
PopDensity2006 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2006_1km_UNadj.xlsx")
PopDensity2007 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2007_1km_UNadj.xlsx")
PopDensity2008 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2008_1km_UNadj.xlsx")
PopDensity2009 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2009_1km_UNadj.xlsx")
PopDensity2010 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2010_1km_UNadj.xlsx")
PopDensity2011 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2011_1km_UNadj.xlsx")
PopDensity2012 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2012_1km_UNadj.xlsx")
PopDensity2013 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2013_1km_UNadj.xlsx")
PopDensity2014 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2014_1km_UNadj.xlsx")
PopDensity2015 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2015_1km_UNadj.xlsx")
PopDensity2016 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2016_1km_UNadj.xlsx")
PopDensity2017 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2017_1km_UNadj.xlsx")
PopDensity2018 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2018_1km_UNadj.xlsx")
PopDensity2019 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2019_1km_UNadj.xlsx")
PopDensity2020 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2020_1km_UNadj.xlsx")

#fix "year" variables
PopDensity1990$Year <- 1990
PopDensity2000$Year <- 2001
PopDensity2001$Year <- 2002
PopDensity2002$Year <- 2003
PopDensity2003$Year <- 2004
PopDensity2004$Year <- 2005
PopDensity2005$Year <- 2006
PopDensity2006$Year <- 2007
PopDensity2007$Year <- 2008
PopDensity2008$Year <- 2009
PopDensity2009$Year <- 2010
PopDensity2010$Year <- 2011
PopDensity2011$Year <- 2012
PopDensity2012$Year <- 2013
PopDensity2013$Year <- 2014
PopDensity2014$Year <- 2015
PopDensity2015$Year <- 2016
PopDensity2016$Year <- 2017
PopDensity2017$Year <- 2018
PopDensity2018$Year <- 2019
PopDensity2019$Year <- 2020
PopDensity2020$Year <- 2021

#combine all years into one dataframe
PopDensity_total <- rbind(PopDensity1990,PopDensity2000, 
                          PopDensity2001,
                          PopDensity2002,
                          PopDensity2003,
                          PopDensity2004,
                          PopDensity2005,
                          PopDensity2006,
                          PopDensity2007,
                          PopDensity2008,
                          PopDensity2009,
                          PopDensity2010,
                          PopDensity2011,
                          PopDensity2012,
                          PopDensity2013,
                          PopDensity2014,
                          PopDensity2015,
                          PopDensity2016,
                          PopDensity2017,
                          PopDensity2018,
                          PopDensity2019,
                          PopDensity2020)

PopDensity_total <- PopDensity_total %>% select(NOM, MEAN, Year)
PopDensity_total <- left_join(PopDensity_total, area_dat, by ="NOM")

#select relevant variables
PopDensity_total2 <- PopDensity_total %>% dplyr::select(NOM, MEAN, Year, AREA) %>% dplyr::rename(Name=NOM, PopDensity=MEAN, area=AREA)

#combine parks from same management unit
PopDensity_total2$Name[PopDensity_total2$Name=="Analamazaotra"]<- "Andasibe/Analamazaotra"
PopDensity_total2$Name[PopDensity_total2$Name=="Mantadia"]<- "Andasibe/Analamazaotra"
PopDensity_total2$Name[PopDensity_total2$Name=="Bemaraha (partie Nord)"]<- "Bemaraha (combined)"
PopDensity_total2$Name[PopDensity_total2$Name=="Bemaraha partie Sud"]<- "Bemaraha (combined)"
PopDensity_total2$Name[PopDensity_total2$Name=="Tsingy de Namoroka"]<- "Namoroka/Baie de Baly"
PopDensity_total2$Name[PopDensity_total2$Name=="Baie de Baly"]<- "Namoroka/Baie de Baly"
PopDensity_total2$Name[PopDensity_total2$Name=="Zahamena RNI"]<- "Zahamena" 
PopDensity_total2$Name[PopDensity_total2$Name=="Foret d'Ambre"]<-  "Montagne d'Ambre" 
PopDensity_total2$Name[PopDensity_total2$Name=="Nosy Mangabe" ]<- "Masoala"


PopDensity_total2 <- PopDensity_total2 %>% dplyr::group_by(Name, Year) %>% dplyr::summarise(PopDensity_old = mean(PopDensity*area), area= mean(area), PopDensity=mean(PopDensity_old)/area)%>% dplyr::select(Name, Year, PopDensity)

area_dat <- PopDensity_total %>% filter (Year!=1990) %>% dplyr::select(NOM, AREA) %>% distinct()%>% rename(Name =NOM, area=AREA)

#save data 
write.csv(PopDensity_total2 , "~/Documents/GitHub/TourismDeforestation/Data/CleanedConfounders/PopDensity.csv")
```

```{r Population Density Compulation -- Commune }
#IMPORT POPULATION DENSITY DATA
PopDensityCommune1990  <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/PopPark1990commune_TableToExcel.xlsx")
PopDensityCommune2000 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2000_1km_UNadjCommune.xlsx")
PopDensityCommune2001 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2001_1km_UNadjCommune.xlsx")
PopDensityCommune2002 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2002_1km_UNadjCommune.xlsx")
PopDensityCommune2003 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2003_1km_UNadjCommune.xlsx")
PopDensityCommune2004 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2004_1km_UNadjCommune.xlsx")
PopDensityCommune2005 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2005_1km_UNadjCommune.xlsx")
PopDensityCommune2006 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2006_1km_UNadjCommune.xlsx")
PopDensityCommune2007 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2007_1km_UNadjCommune.xlsx")
PopDensityCommune2008 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2008_1km_UNadjCommune.xlsx")
PopDensityCommune2009 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2009_1km_UNadjCommune.xlsx")
PopDensityCommune2010 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2010_1km_UNadjCommune.xlsx")
PopDensityCommune2011 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2011_1km_UNadjCommune.xlsx")
PopDensityCommune2012 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2012_1km_UNadjCommune.xlsx")
PopDensityCommune2013 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2013_1km_UNadjCommune.xlsx")
PopDensityCommune2014 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2014_1km_UNadjCommune.xlsx")
PopDensityCommune2015 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2015_1km_UNadjCommune.xlsx")
PopDensityCommune2016 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2016_1km_UNadjCommune.xlsx")
PopDensityCommune2017 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2017_1km_UNadjCommune.xlsx")
PopDensityCommune2018 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2018_1km_UNadjCommune.xlsx")
PopDensityCommune2019 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2019_1km_UNadjCommune.xlsx")
PopDensityCommune2020 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopulationDensity/ZonalSt_MNP_Popmdg_pd_2020_1km_UNadjCommune.xlsx")
#fix "year" variables
PopDensityCommune2000$Year <- 2001
PopDensityCommune2001$Year <- 2002
PopDensityCommune2002$Year <- 2003
PopDensityCommune2003$Year <- 2004
PopDensityCommune2004$Year <- 2005
PopDensityCommune2005$Year <- 2006
PopDensityCommune2006$Year <- 2007
PopDensityCommune2007$Year <- 2008
PopDensityCommune2008$Year <- 2009
PopDensityCommune2009$Year <- 2010
PopDensityCommune2010$Year <- 2011
PopDensityCommune2011$Year <- 2012
PopDensityCommune2012$Year <- 2013
PopDensityCommune2013$Year <- 2014
PopDensityCommune2014$Year <- 2015
PopDensityCommune2015$Year <- 2016
PopDensityCommune2016$Year <- 2017
PopDensityCommune2017$Year <- 2018
PopDensityCommune2018$Year <- 2019
PopDensityCommune2019$Year <- 2020
PopDensityCommune2020$Year <- 2021

#combine all years into one dataframe
PopDensityCommune_total <- rbind(PopDensityCommune2000, 
                          PopDensityCommune2001,
                          PopDensityCommune2002,
                          PopDensityCommune2003,
                          PopDensityCommune2004,
                          PopDensityCommune2005,
                          PopDensityCommune2006,
                          PopDensityCommune2007,
                          PopDensityCommune2008,
                          PopDensityCommune2009,
                          PopDensityCommune2010,
                          PopDensityCommune2011,
                          PopDensityCommune2012,
                          PopDensityCommune2013,
                          PopDensityCommune2014,
                          PopDensityCommune2015,
                          PopDensityCommune2016,
                          PopDensityCommune2017,
                          PopDensityCommune2018,
                          PopDensityCommune2019,
                          PopDensityCommune2020)

PopDensityCommune_total <- PopDensityCommune_total %>% select(NOM, MEAN, Year)
PopDensityCommune_total <- left_join(PopDensityCommune_total, area_dat_commune, by="NOM")

#select relevant variables
PopDensityCommune_total2 <- PopDensityCommune_total %>% dplyr::select(NOM, MEAN, Year, AREA) %>% dplyr::rename(Name=NOM, PopDensityCommune=MEAN, area=AREA )

#combine parks from same management unit
PopDensityCommune_total2$Name[PopDensityCommune_total2$Name=="Analamazaotra"]<- "Andasibe/Analamazaotra"
PopDensityCommune_total2$Name[PopDensityCommune_total2$Name=="Mantadia"]<- "Andasibe/Analamazaotra"
PopDensityCommune_total2$Name[PopDensityCommune_total2$Name=="Bemaraha (partie Nord)"]<- "Bemaraha (combined)"
PopDensityCommune_total2$Name[PopDensityCommune_total2$Name=="Bemaraha partie Sud"]<- "Bemaraha (combined)"
PopDensityCommune_total2$Name[PopDensityCommune_total2$Name=="Tsingy de Namoroka"]<- "Namoroka/Baie de Baly"
PopDensityCommune_total2$Name[PopDensityCommune_total2$Name=="Baie de Baly"]<- "Namoroka/Baie de Baly"
PopDensityCommune_total2$Name[PopDensityCommune_total2$Name=="Foret d'Ambre"]<-  "Montagne d'Ambre" 
PopDensityCommune_total2$Name[PopDensityCommune_total2$Name=="Nosy Mangabe" ]<- "Masoala"

PopDensityCommune_total2 <- PopDensityCommune_total2 %>% dplyr::group_by(Name, Year) %>%dplyr::summarise(PopDensity_old = mean(PopDensityCommune*area), area= mean(area), PopDensityCommune=mean(PopDensity_old)/area)%>% dplyr::select(Name, Year, PopDensityCommune)

area_dat_commune <- PopDensityCommune_total %>% filter (Year!=1990) %>% dplyr::select(NOM, AREA) %>% distinct()%>% rename(Name =NOM, area=AREA)

#save data 
write.csv(PopDensityCommune_total2 , "~/Documents/GitHub/TourismDeforestation/Data/CleanedConfounders/PopDensityCommune.csv")
```

```{r Funding -- Full and Commune}
#Import the data 
funding <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/funding_updated.csv")

#Select relevant data for our analyses
funding_tourism2 <- funding %>% pivot_longer(cols=X2004:X2011, names_to="year", values_to="funding_tourism") 
funding_tourism2$Year <- as.numeric(gsub("X", "", funding_tourism2$year))
funding_tourism2 <- funding_tourism2[,-2]
funding_tourism2$Year <- funding_tourism2$Year +1
funding_tourism2$funding <- log(funding_tourism2$funding_tourism+1)
area_dat_funding <- area_dat
area_dat_funding$Name[area_dat_funding$Name=="Analamazaotra"]<- "Andasibe/Analamazaotra"
area_dat_funding$Name[area_dat_funding$Name=="Mantadia"]<- "Andasibe/Analamazaotra"
area_dat_funding$Name[area_dat_funding$Name=="Bemaraha (partie Nord)"]<- "Bemaraha (combined)"
area_dat_funding$Name[area_dat_funding$Name=="Bemaraha partie Sud"]<- "Bemaraha (combined)"
area_dat_funding$Name[area_dat_funding$Name=="Tsingy de Namoroka"]<- "Namoroka/Baie de Baly"
area_dat_funding$Name[area_dat_funding$Name=="Baie de Baly"]<- "Namoroka/Baie de Baly"
area_dat_funding$Name[area_dat_funding$Name=="Foret d'Ambre"]<-  "Montagne d'Ambre" 
area_dat_funding$Name[area_dat_funding$Name=="Nosy Mangabe" ]<- "Masoala"
area_dat_funding2 <- area_dat_funding %>% dplyr::group_by(Name) %>%dplyr::summarise(area =sum(area))

funding_tourism3 <- left_join(funding_tourism2, area_dat_funding2, by="Name")
funding_tourism3$funding_by_area <- funding_tourism3$funding/funding_tourism3$area
funding_tourism3$funding_by_area <- log(funding_tourism3$funding_by_area+1)

write.csv(funding_tourism3, "~/Documents/GitHub/TourismDeforestation/Data/CleanedConfounders/Funding.csv")

```

```{r Forest loss proportion-- Full}
#read tourism and deforestation data
#read tourism and deforestation data
deforestation_dat1990 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/MNP1990fc.csv")
deforestation_dat2000 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2000.csv")
deforestation_dat2001 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2001.csv")
deforestation_dat2002 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2002.csv")
deforestation_dat2003 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2003.csv")
deforestation_dat2004 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2004.csv")
deforestation_dat2005 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2005.csv")
deforestation_dat2006 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2006.csv")
deforestation_dat2007 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2007.csv")
deforestation_dat2008 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2008.csv")
deforestation_dat2009 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2009.csv")
deforestation_dat2010 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2010.csv")
deforestation_dat2011 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2011.csv")
deforestation_dat2012 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2012.csv")
deforestation_dat2013 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2013.csv")
deforestation_dat2014 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2014.csv")
deforestation_dat2015 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2015.csv")
deforestation_dat2016 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2016.csv")
deforestation_dat2017 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2017.csv")
deforestation_dat2018 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2018.csv")
deforestation_dat2019 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2019.csv")
deforestation_dat2020 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2020.csv")
deforestation_dat2021 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cff2021.csv")

deforestation_dat1990$Year <- "fc1990"
deforestation_dat2000$Year <- "fc2000"
deforestation_dat2001$Year <- "fc2001"
deforestation_dat2002$Year <- "fc2002"
deforestation_dat2003$Year <- "fc2003"
deforestation_dat2004$Year <- "fc2004"
deforestation_dat2005$Year <- "fc2005"
deforestation_dat2006$Year <- "fc2006"
deforestation_dat2007$Year <- "fc2007"
deforestation_dat2008$Year <- "fc2008"
deforestation_dat2009$Year <- "fc2009"
deforestation_dat2010$Year <- "fc2010"
deforestation_dat2011$Year <- "fc2011"
deforestation_dat2012$Year <- "fc2012"
deforestation_dat2013$Year <- "fc2013"
deforestation_dat2014$Year <- "fc2014"
deforestation_dat2015$Year <- "fc2015"
deforestation_dat2016$Year <- "fc2016"
deforestation_dat2017$Year <- "fc2017"
deforestation_dat2018$Year <- "fc2018"
deforestation_dat2019$Year <- "fc2019"
deforestation_dat2020$Year <- "fc2020"
deforestation_dat2021$Year <- "fc2021"
deforestation_dat2000$Year <- "fc2000"

deforestation_dat1990 <- deforestation_dat1990 %>% dplyr::select(NOM, SUM, Year)
deforestation_dat2000 <- deforestation_dat2000 %>% dplyr::select(NOM, SUM, Year)

deforestation_dat <- rbind(deforestation_dat2001, deforestation_dat2002, deforestation_dat2003, deforestation_dat2004, deforestation_dat2005, deforestation_dat2006, deforestation_dat2007, deforestation_dat2008, deforestation_dat2009, deforestation_dat2010, deforestation_dat2011, deforestation_dat2012, deforestation_dat2013, deforestation_dat2014, deforestation_dat2015, deforestation_dat2016, deforestation_dat2017, deforestation_dat2018, deforestation_dat2019, deforestation_dat2020, deforestation_dat2021)

deforestation_dat <- deforestation_dat %>% dplyr::select(NOM, SUM, Year)
deforestation_dat2 <- rbind(deforestation_dat, deforestation_dat1990)
deforestation_dat2 <- rbind(deforestation_dat2, deforestation_dat2000)

deforestation_dat2 <- deforestation_dat2%>% pivot_wider(names_from = "Year", values_from= "SUM")


            

deforestation_dat2$flp2001 <- (deforestation_dat2$fc2000 - deforestation_dat2$fc2001)/ deforestation_dat2$fc2000
deforestation_dat2$flp2002 <- (deforestation_dat2$fc2001 - deforestation_dat2$fc2002)/ deforestation_dat2$fc2000
deforestation_dat2$flp2003 <- (deforestation_dat2$fc2002 - deforestation_dat2$fc2003)/ deforestation_dat2$fc2000
deforestation_dat2$flp2004 <- (deforestation_dat2$fc2003 - deforestation_dat2$fc2004)/ deforestation_dat2$fc2000
deforestation_dat2$flp2005 <- (deforestation_dat2$fc2004 - deforestation_dat2$fc2005)/ deforestation_dat2$fc2000
deforestation_dat2$flp2006 <- (deforestation_dat2$fc2005 - deforestation_dat2$fc2006)/ deforestation_dat2$fc2000
deforestation_dat2$flp2007 <- (deforestation_dat2$fc2006 - deforestation_dat2$fc2007)/ deforestation_dat2$fc2000
deforestation_dat2$flp2008 <- (deforestation_dat2$fc2007 - deforestation_dat2$fc2008)/ deforestation_dat2$fc2000
deforestation_dat2$flp2009 <- (deforestation_dat2$fc2008 - deforestation_dat2$fc2009)/ deforestation_dat2$fc2000
deforestation_dat2$flp2010 <- (deforestation_dat2$fc2009 - deforestation_dat2$fc2010)/ deforestation_dat2$fc2000
deforestation_dat2$flp2011 <- (deforestation_dat2$fc2010 - deforestation_dat2$fc2011)/ deforestation_dat2$fc2000
deforestation_dat2$flp2012 <- (deforestation_dat2$fc2011 - deforestation_dat2$fc2012)/ deforestation_dat2$fc2000
deforestation_dat2$flp2013 <- (deforestation_dat2$fc2012 - deforestation_dat2$fc2013)/ deforestation_dat2$fc2000
deforestation_dat2$flp2014 <- (deforestation_dat2$fc2013 - deforestation_dat2$fc2014)/ deforestation_dat2$fc2000
deforestation_dat2$flp2015 <- (deforestation_dat2$fc2014 - deforestation_dat2$fc2015)/ deforestation_dat2$fc2000
deforestation_dat2$flp2016 <- (deforestation_dat2$fc2015 - deforestation_dat2$fc2016)/ deforestation_dat2$fc2000
deforestation_dat2$flp2017 <- (deforestation_dat2$fc2016 - deforestation_dat2$fc2017)/ deforestation_dat2$fc2000
deforestation_dat2$flp2018 <- (deforestation_dat2$fc2017 - deforestation_dat2$fc2018)/ deforestation_dat2$fc2000
deforestation_dat2$flp2019 <- (deforestation_dat2$fc2018 - deforestation_dat2$fc2019)/ deforestation_dat2$fc2000
deforestation_dat2$flp2020 <- (deforestation_dat2$fc2019 - deforestation_dat2$fc2020)/ deforestation_dat2$fc2000
deforestation_dat2$flp2021 <- (deforestation_dat2$fc2020 - deforestation_dat2$fc2021)/ deforestation_dat2$fc2000


deforestation_dat2_funding <- deforestation_dat2

deforestation_dat2_funding$flp2005 <- (deforestation_dat2$fc2004 - deforestation_dat2$fc2005)/ deforestation_dat2$fc2004
deforestation_dat2_funding$flp2006 <- (deforestation_dat2$fc2005 - deforestation_dat2$fc2004)/ deforestation_dat2$fc2004
deforestation_dat2_funding$flp2007 <- (deforestation_dat2$fc2006 - deforestation_dat2$fc2007)/ deforestation_dat2$fc2004
deforestation_dat2_funding$flp2008 <- (deforestation_dat2$fc2007 - deforestation_dat2$fc2008)/ deforestation_dat2$fc2004
deforestation_dat2_funding$flp2009 <- (deforestation_dat2$fc2008 - deforestation_dat2$fc2009)/ deforestation_dat2$fc2004
deforestation_dat2_funding$flp2010 <- (deforestation_dat2$fc2009 - deforestation_dat2$fc2010)/ deforestation_dat2$fc2004
deforestation_dat2_funding$flp2011 <- (deforestation_dat2$fc2010 - deforestation_dat2$fc2011)/ deforestation_dat2$fc2004
deforestation_dat2_funding$flp2012 <- (deforestation_dat2$fc2011 - deforestation_dat2$fc2012)/ deforestation_dat2$fc2004

deforestation_dat3 <- deforestation_dat2 %>% dplyr::select(NOM, flp2001:flp2021) %>% pivot_longer(cols=flp2001:flp2021, names_to="Year", values_to="PercentDeforest") %>% rename(Name=NOM)
deforestation_dat3$Year <- gsub( "flp", "", deforestation_dat3$Year)
deforestation_dat3$Year <- as.numeric(deforestation_dat3$Year)
fc2000 <-  deforestation_dat2 %>% select(NOM, fc2000) %>% rename(Name = NOM)
deforestation_dat3<- left_join(deforestation_dat3, fc2000, by="Name")
deforestation_dat3_funding <- deforestation_dat2_funding %>% dplyr::select(NOM, flp2005:flp2012) %>% pivot_longer(cols=flp2005:flp2012, names_to="Year", values_to="PercentDeforest") %>% rename(Name=NOM)
deforestation_dat3_funding$Year <- gsub( "flp", "", deforestation_dat3_funding$Year)
deforestation_dat3_funding$Year <- as.numeric(deforestation_dat3_funding$Year)

deforestation_dat3_funding <- left_join(deforestation_dat3_funding, fc2000, by="Name")

deforestation_dat3$Name[deforestation_dat3$Name=="Analamazaotra"]<- "Andasibe/Analamazaotra"
deforestation_dat3$Name[deforestation_dat3$Name=="Mantadia"]<- "Andasibe/Analamazaotra"
deforestation_dat3$Name[deforestation_dat3$Name=="Bemaraha (partie Nord)"]<- "Bemaraha (combined)"
deforestation_dat3$Name[deforestation_dat3$Name=="Bemaraha partie Sud"]<- "Bemaraha (combined)"
deforestation_dat3$Name[deforestation_dat3$Name=="Tsingy de Namoroka"]<- "Namoroka/Baie de Baly"
deforestation_dat3$Name[deforestation_dat3$Name=="Baie de Baly"]<- "Namoroka/Baie de Baly"
deforestation_dat3$Name[deforestation_dat3$Name=="Zahamena RNI"]<- "Zahamena" 
deforestation_dat3$Name[deforestation_dat3$Name=="Nosy Mangabe"]<- "Masoala"
deforestation_dat3$Name[deforestation_dat3$Name=="Foret d'Ambre"]<-  "Montagne d'Ambre" 


deforestation_dat3 <- deforestation_dat3 %>% dplyr::group_by(Name, Year) %>% dplyr::summarise(PercentDeforest_old = mean(PercentDeforest*fc2000), area=mean(fc2000), PercentDeforest=mean(PercentDeforest_old)/area)%>% dplyr::select(Name, Year, PercentDeforest)

write.csv(deforestation_dat3, "~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/deforestation_full.csv")

write.csv(deforestation_dat, "~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/deforestation_dat1.csv")

deforestation_dat3_funding$Name[deforestation_dat3_funding$Name=="Analamazaotra"]<- "Andasibe/Analamazaotra"
deforestation_dat3_funding$Name[deforestation_dat3_funding$Name=="Mantadia"]<- "Andasibe/Analamazaotra"
deforestation_dat3_funding$Name[deforestation_dat3_funding$Name=="Bemaraha (partie Nord)"]<- "Bemaraha (combined)"
deforestation_dat3_funding$Name[deforestation_dat3_funding$Name=="Bemaraha partie Sud"]<- "Bemaraha (combined)"
deforestation_dat3_funding$Name[deforestation_dat3_funding$Name=="Tsingy de Namoroka"]<- "Namoroka/Baie de Baly"
deforestation_dat3_funding$Name[deforestation_dat3_funding$Name=="Baie de Baly"]<- "Namoroka/Baie de Baly"
deforestation_dat3_funding$Name[deforestation_dat3_funding$Name=="Zahamena RNI"]<- "Zahamena" 
deforestation_dat3_funding$Name[deforestation_dat3_funding$Name=="Nosy Mangabe"]<- "Masoala"
deforestation_dat3_funding$Name[deforestation_dat3_funding$Name=="Foret d'Ambre"]<-  "Montagne d'Ambre" 

deforestation_dat3_funding <- deforestation_dat3_funding %>% dplyr::group_by(Name, Year)%>% dplyr::summarise(PercentDeforest_old = mean(PercentDeforest*fc2000), area=mean(fc2000), PercentDeforest=mean(PercentDeforest_old)/area)%>% dplyr::select(Name, Year, PercentDeforest)

write.csv(deforestation_dat3_funding, "~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/deforestation_full_funding.csv")

```

```{r Forest loss proportion-- Commune}
#read tourism and deforestation data
deforestation_dat_commune1990 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/commune_1990.csv")
deforestation_dat_commune2000 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2000.csv")
deforestation_dat_commune2001 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2001b.csv")
deforestation_dat_commune2002 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2002.csv")
deforestation_dat_commune2003 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2003.csv")
deforestation_dat_commune2004 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2004.csv")
deforestation_dat_commune2005 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2005.csv")
deforestation_dat_commune2006 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2006.csv")
deforestation_dat_commune2007 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2007.csv")
deforestation_dat_commune2008 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2008.csv")
deforestation_dat_commune2009 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2009.csv")
deforestation_dat_commune2010 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2010.csv")
deforestation_dat_commune2011 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2011.csv")
deforestation_dat_commune2012 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2012.csv")
deforestation_dat_commune2013 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2013.csv")
deforestation_dat_commune2014 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2014.csv")
deforestation_dat_commune2015 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2015.csv")
deforestation_dat_commune2016 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2016.csv")
deforestation_dat_commune2017 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2017.csv")
deforestation_dat_commune2018 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2018.csv")
deforestation_dat_commune2019 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2019.csv")
deforestation_dat_commune2020 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2020.csv")
deforestation_dat_commune2021 <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/cfc2021b.csv")
deforestation_dat_commune1990$Year <- "fc1990"
deforestation_dat_commune2001$Year <- "fc2001"
deforestation_dat_commune2002$Year <- "fc2002"
deforestation_dat_commune2003$Year <- "fc2003"
deforestation_dat_commune2004$Year <- "fc2004"
deforestation_dat_commune2005$Year <- "fc2005"
deforestation_dat_commune2006$Year <- "fc2006"
deforestation_dat_commune2007$Year <- "fc2007"
deforestation_dat_commune2008$Year <- "fc2008"
deforestation_dat_commune2009$Year <- "fc2009"
deforestation_dat_commune2010$Year <- "fc2010"
deforestation_dat_commune2011$Year <- "fc2011"
deforestation_dat_commune2012$Year <- "fc2012"
deforestation_dat_commune2013$Year <- "fc2013"
deforestation_dat_commune2014$Year <- "fc2014"
deforestation_dat_commune2015$Year <- "fc2015"
deforestation_dat_commune2016$Year <- "fc2016"
deforestation_dat_commune2017$Year <- "fc2017"
deforestation_dat_commune2018$Year <- "fc2018"
deforestation_dat_commune2019$Year <- "fc2019"
deforestation_dat_commune2020$Year <- "fc2020"
deforestation_dat_commune2021$Year <- "fc2021"
deforestation_dat_commune2000$Year <- "fc2000"

deforestation_dat_commune1990 <- deforestation_dat_commune1990 %>% dplyr::select(NOM, SUM, Year)
deforestation_dat_commune2000 <- deforestation_dat_commune2000 %>% dplyr::select(NOM, SUM, Year)

deforestation_dat_commune <- rbind(deforestation_dat_commune2001, deforestation_dat_commune2002, deforestation_dat_commune2003, deforestation_dat_commune2004, deforestation_dat_commune2005, deforestation_dat_commune2006, deforestation_dat_commune2007, deforestation_dat_commune2008, deforestation_dat_commune2009, deforestation_dat_commune2010, deforestation_dat_commune2011, deforestation_dat_commune2012, deforestation_dat_commune2013, deforestation_dat_commune2014, deforestation_dat_commune2015, deforestation_dat_commune2016, deforestation_dat_commune2017, deforestation_dat_commune2018, deforestation_dat_commune2019, deforestation_dat_commune2020, deforestation_dat_commune2021)

deforestation_dat_commune <- deforestation_dat_commune %>% dplyr::select(NOM, SUM, Year)
deforestation_dat_commune2 <- rbind(deforestation_dat_commune, deforestation_dat_commune1990)
deforestation_dat_commune2 <- rbind(deforestation_dat_commune2, deforestation_dat_commune2000)

deforestation_dat_commune2 <- deforestation_dat_commune2%>% pivot_wider(names_from = "Year", values_from= "SUM")


                         

deforestation_dat_commune2$flp2001 <- (deforestation_dat_commune2$fc2000 - deforestation_dat_commune2$fc2001)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2002 <- (deforestation_dat_commune2$fc2001 - deforestation_dat_commune2$fc2002)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2003 <- (deforestation_dat_commune2$fc2002 - deforestation_dat_commune2$fc2003)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2004 <- (deforestation_dat_commune2$fc2003 - deforestation_dat_commune2$fc2004)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2005 <- (deforestation_dat_commune2$fc2004 - deforestation_dat_commune2$fc2005)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2006 <- (deforestation_dat_commune2$fc2005 - deforestation_dat_commune2$fc2006)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2007 <- (deforestation_dat_commune2$fc2006 - deforestation_dat_commune2$fc2007)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2008 <- (deforestation_dat_commune2$fc2007 - deforestation_dat_commune2$fc2008)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2009 <- (deforestation_dat_commune2$fc2008 - deforestation_dat_commune2$fc2009)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2010 <- (deforestation_dat_commune2$fc2009 - deforestation_dat_commune2$fc2010)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2011 <- (deforestation_dat_commune2$fc2010 - deforestation_dat_commune2$fc2011)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2012 <- (deforestation_dat_commune2$fc2011 - deforestation_dat_commune2$fc2012)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2013 <- (deforestation_dat_commune2$fc2012 - deforestation_dat_commune2$fc2013)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2014 <- (deforestation_dat_commune2$fc2013 - deforestation_dat_commune2$fc2014)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2015 <- (deforestation_dat_commune2$fc2014 - deforestation_dat_commune2$fc2015)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2016 <- (deforestation_dat_commune2$fc2015 - deforestation_dat_commune2$fc2016)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2017 <- (deforestation_dat_commune2$fc2016 - deforestation_dat_commune2$fc2017)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2018 <- (deforestation_dat_commune2$fc2017 - deforestation_dat_commune2$fc2018)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2019 <- (deforestation_dat_commune2$fc2018 - deforestation_dat_commune2$fc2019)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2020 <- (deforestation_dat_commune2$fc2019 - deforestation_dat_commune2$fc2020)/ deforestation_dat_commune2$fc2000
deforestation_dat_commune2$flp2021 <- (deforestation_dat_commune2$fc2020 - deforestation_dat_commune2$fc2021)/ deforestation_dat_commune2$fc2000

andringitra <- as.list(c("Andringitra",rep(0, times=44)))
deforestation_dat_commune2 <- rbind(deforestation_dat_commune2, andringitra)

deforestation_dat_commune2_funding <- deforestation_dat_commune2
deforestation_dat_commune2_funding$fc2004 <- as.numeric(deforestation_dat_commune2_funding$fc2004)
deforestation_dat_commune2_funding$fc2005 <- as.numeric(deforestation_dat_commune2_funding$fc2005)
deforestation_dat_commune2_funding$fc2006 <- as.numeric(deforestation_dat_commune2_funding$fc2006)
deforestation_dat_commune2_funding$fc2007 <- as.numeric(deforestation_dat_commune2_funding$fc2007)
deforestation_dat_commune2_funding$fc2008 <- as.numeric(deforestation_dat_commune2_funding$fc2008)
deforestation_dat_commune2_funding$fc2009 <- as.numeric(deforestation_dat_commune2_funding$fc2009)
deforestation_dat_commune2_funding$fc2010 <- as.numeric(deforestation_dat_commune2_funding$fc2010)
deforestation_dat_commune2_funding$fc2011 <- as.numeric(deforestation_dat_commune2_funding$fc2011)
deforestation_dat_commune2_funding$fc2012 <- as.numeric(deforestation_dat_commune2_funding$fc2012)

deforestation_dat_commune2_funding$flp2005 <- (deforestation_dat_commune2_funding$fc2004 - deforestation_dat_commune2_funding$fc2005)/ deforestation_dat_commune2_funding$fc2004
deforestation_dat_commune2_funding$flp2006 <- (deforestation_dat_commune2_funding$fc2005 - deforestation_dat_commune2_funding$fc2004)/ deforestation_dat_commune2_funding$fc2004
deforestation_dat_commune2_funding$flp2007 <- (deforestation_dat_commune2_funding$fc2006 - deforestation_dat_commune2_funding$fc2007)/ deforestation_dat_commune2_funding$fc2004
deforestation_dat_commune2_funding$flp2008 <- (deforestation_dat_commune2_funding$fc2007 - deforestation_dat_commune2_funding$fc2008)/ deforestation_dat_commune2_funding$fc2004
deforestation_dat_commune2_funding$flp2009 <- (deforestation_dat_commune2_funding$fc2008 - deforestation_dat_commune2_funding$fc2009)/ deforestation_dat_commune2_funding$fc2004
deforestation_dat_commune2_funding$flp2010 <- (deforestation_dat_commune2_funding$fc2009 - deforestation_dat_commune2_funding$fc2010)/ deforestation_dat_commune2_funding$fc2004
deforestation_dat_commune2_funding$flp2011 <- (deforestation_dat_commune2_funding$fc2010 - deforestation_dat_commune2_funding$fc2011)/ deforestation_dat_commune2_funding$fc2004
deforestation_dat_commune2_funding$flp2012 <- (deforestation_dat_commune2_funding$fc2011 - deforestation_dat_commune2_funding$fc2012)/ deforestation_dat_commune2_funding$fc2004

deforestation_dat_commune3 <- deforestation_dat_commune2 %>% dplyr::select(NOM, flp2001:flp2021) %>% pivot_longer(cols=flp2001:flp2021, names_to="Year", values_to="PercentDeforest") %>% rename(Name=NOM)
deforestation_dat_commune3$Year <- gsub( "flp", "", deforestation_dat_commune3$Year)
deforestation_dat_commune3$Year <- as.numeric(deforestation_dat_commune3$Year)

fc2000_commune <-  deforestation_dat_commune2 %>% select(NOM, fc2000) %>% rename(Name = NOM)
fc2000_commune$fc2000 <- as.numeric(fc2000_commune$fc2000)
deforestation_dat_commune3 <- left_join(deforestation_dat_commune3, fc2000_commune, by="Name")

deforestation_dat_commune3$Name[deforestation_dat_commune3$Name=="Analamazaotra"]<- "Andasibe/Analamazaotra"
deforestation_dat_commune3$Name[deforestation_dat_commune3$Name=="Mantadia"]<- "Andasibe/Analamazaotra"
deforestation_dat_commune3$Name[deforestation_dat_commune3$Name=="Bemaraha (partie Nord)"]<- "Bemaraha (combined)"
deforestation_dat_commune3$Name[deforestation_dat_commune3$Name=="Bemaraha partie Sud"]<- "Bemaraha (combined)"
deforestation_dat_commune3$Name[deforestation_dat_commune3$Name=="Tsingy de Namoroka"]<- "Namoroka/Baie de Baly"
deforestation_dat_commune3$Name[deforestation_dat_commune3$Name=="Baie de Baly"]<- "Namoroka/Baie de Baly"
deforestation_dat_commune3$Name[deforestation_dat_commune3$Name=="Zahamena RNI"]<-  "Zahamena" 
deforestation_dat_commune3$Name[deforestation_dat_commune3$Name=="Nosy Mangabe"]<- "Masoala" 
deforestation_dat_commune3$Name[deforestation_dat_commune3$Name=="Foret d'Ambre"]<-  "Montagne d'Ambre" 
deforestation_dat_commune3$PercentDeforest <- as.numeric(deforestation_dat_commune3$PercentDeforest)


deforestation_dat_commune3 <- deforestation_dat_commune3 %>% dplyr::group_by(Name, Year)%>% dplyr::summarise(PercentDeforest_old = mean(PercentDeforest*fc2000), area=mean(fc2000), PercentDeforest=mean(PercentDeforest_old)/area)%>% dplyr::select(Name, Year, PercentDeforest)

write.csv(deforestation_dat_commune3, "~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/deforestation_commune.csv")

deforestation_dat_commune3_funding <- deforestation_dat_commune2_funding %>% dplyr::select(NOM, flp2005:flp2012) %>% pivot_longer(cols=flp2005:flp2012, names_to="Year", values_to="PercentDeforest") %>% rename(Name=NOM)
deforestation_dat_commune3_funding$Year <- gsub( "flp", "", deforestation_dat_commune3_funding$Year)
deforestation_dat_commune3_funding$Year <- as.numeric(deforestation_dat_commune3_funding$Year)
deforestation_dat_commune3_funding <- left_join(deforestation_dat_commune3_funding, fc2000_commune, by="Name")

deforestation_dat_commune3_funding$Name[deforestation_dat_commune3_funding$Name=="Analamazaotra"]<- "Andasibe/Analamazaotra"
deforestation_dat_commune3_funding$Name[deforestation_dat_commune3_funding$Name=="Mantadia"]<- "Andasibe/Analamazaotra"
deforestation_dat_commune3_funding$Name[deforestation_dat_commune3_funding$Name=="Bemaraha (partie Nord)"]<- "Bemaraha (combined)"
deforestation_dat_commune3_funding$Name[deforestation_dat_commune3_funding$Name=="Bemaraha partie Sud"]<- "Bemaraha (combined)"
deforestation_dat_commune3_funding$Name[deforestation_dat_commune3_funding$Name=="Tsingy de Namoroka"]<- "Namoroka/Baie de Baly"
deforestation_dat_commune3_funding$Name[deforestation_dat_commune3_funding$Name=="Baie de Baly"]<- "Namoroka/Baie de Baly"
deforestation_dat_commune3_funding$Name[deforestation_dat_commune3_funding$Name=="Zahamena RNI"]<-  "Zahamena" 
deforestation_dat_commune3_funding$Name[deforestation_dat_commune3_funding$Name=="Nosy Mangabe"]<- "Masoala" 
deforestation_dat_commune3_funding$Name[deforestation_dat_commune3_funding$Name=="Foret d'Ambre"]<-  "Montagne d'Ambre" 

deforestation_dat_commune3_funding$PercentDeforest <- as.numeric(deforestation_dat_commune3_funding$PercentDeforest)
deforestation_dat_commune3_funding <- deforestation_dat_commune3_funding %>% dplyr::group_by(Name, Year) %>% dplyr::summarise(PercentDeforest_old = mean(PercentDeforest*fc2000), area=mean(fc2000), PercentDeforest=mean(PercentDeforest_old)/area)%>% dplyr::select(Name, Year, PercentDeforest)

write.csv(deforestation_dat_commune3_funding, "~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/deforestation_commune_funding.csv")


```

```{r Tourism}
tourism <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/tourism_deforestation.csv")
tourism <- tourism %>% dplyr::select(Name, Tourism, Year)


tourism$Name[tourism$Name=="Analamazaotra"]<- "Andasibe/Analamazaotra"
tourism$Name[tourism$Name=="Mantadia"]<- "Andasibe/Analamazaotra"
tourism$Name[tourism$Name=="Bemaraha (partie Nord)"]<- "Bemaraha (combined)"
tourism$Name[tourism$Name=="Bemaraha partie Sud"]<- "Bemaraha (combined)"
tourism$Name[tourism$Name=="Tsingy de Namoroka"]<- "Namoroka/Baie de Baly"
tourism$Name[tourism$Name=="Baie de Baly"]<- "Namoroka/Baie de Baly"
tourism$Name[tourism$Name=="Zahamena RNI"]<- "Zahamena"
tourism$Name[tourism$Name=="Nosy Mangabe"]<- "Masoala"
tourism$Name[tourism$Name=="Foret d'Ambre"]<-  "Montagne d'Ambre" 
tourism$Tourism[is.na(tourism$Tourism)] <- 0
tourism <- tourism[tourism$Name!="Mikea"|tourism$Name!="Sahamalaza",]

tourism <- tourism %>% dplyr::group_by(Name, Year) %>% dplyr::summarise(Tourism = sum(Tourism))

tourism_full <- tourism %>% filter(Year >=2000)

write.csv(tourism, "~/Documents/GitHub/TourismDeforestation/Data/tourism.csv")


```

```{r Aggregate analysis}

#deforestation data

deforestation_dat2$agg2000 <- (deforestation_dat2$fc1990 - deforestation_dat2$fc2000)/ deforestation_dat2$fc1990

deforestation_dat2$agg2010 <- (deforestation_dat2$fc2000 - deforestation_dat2$fc2010)/ deforestation_dat2$fc1990

deforestation_dat2$agg2020 <- (deforestation_dat2$fc2010 - deforestation_dat2$fc2020)/ deforestation_dat2$fc1990


deforestation_dat_agg <- deforestation_dat2 %>% dplyr::select(NOM, agg2000, agg2010, agg2020) %>% pivot_longer(cols=agg2000:agg2020, names_to="Year", values_to="PercentDeforest") %>% rename(Name=NOM)
deforestation_dat_agg$Year <- gsub( "agg", "", deforestation_dat_agg$Year)
deforestation_dat_agg$Year <- as.numeric(deforestation_dat_agg$Year)
fc1990 <-  deforestation_dat2 %>% select(NOM, fc1990) %>% rename(Name = NOM)
fc1990$fc1990 <- as.numeric(fc1990$fc1990)
deforestation_dat_agg <- left_join(deforestation_dat_agg, fc1990, by="Name")

deforestation_dat_agg$Name[deforestation_dat_agg$Name=="Analamazaotra"]<- "Andasibe/Analamazaotra"
deforestation_dat_agg$Name[deforestation_dat_agg$Name=="Mantadia"]<- "Andasibe/Analamazaotra"
deforestation_dat_agg$Name[deforestation_dat_agg$Name=="Bemaraha (partie Nord)"]<- "Bemaraha (combined)"
deforestation_dat_agg$Name[deforestation_dat_agg$Name=="Bemaraha partie Sud"]<- "Bemaraha (combined)"
deforestation_dat_agg$Name[deforestation_dat_agg$Name=="Tsingy de Namoroka"]<- "Namoroka/Baie de Baly"
deforestation_dat_agg$Name[deforestation_dat_agg$Name=="Baie de Baly"]<- "Namoroka/Baie de Baly"
deforestation_dat_agg$Name[deforestation_dat_agg$Name=="Zahamena RNI"]<- "Zahamena" 
deforestation_dat_agg$Name[deforestation_dat_agg$Name=="Nosy Mangabe"]<- "Masoala"
deforestation_dat_agg$Name[deforestation_dat_agg$Name=="Foret d'Ambre"]<-  "Montagne d'Ambre" 

#tourism
tourism_agg2000 <- tourism %>% filter (Year<=2000) %>% group_by(Name)%>% summarise(Tourism2000 =sum(Tourism))
tourism_agg2010 <- tourism %>% filter (Year<=2010,Year >2000) %>% group_by(Name)%>% summarise(Tourism2010 =sum(Tourism))
tourism_agg2020 <- tourism %>% filter (Year<=2020,Year>2010) %>% group_by(Name)%>% summarise(Tourism2020 = sum(Tourism))

tourism_agg <- left_join(tourism_agg2000, tourism_agg2010, by="Name")
tourism_agg <- left_join(tourism_agg, tourism_agg2020, by="Name")
tourism_agg <- tourism_agg %>% pivot_longer(cols = Tourism2000:Tourism2020, names_to="Year", values_to="Tourism") 
tourism_agg$Year <- gsub("Tourism", "" ,tourism_agg$Year)


tourism_agg$Name[tourism_agg$Name=="Analamazaotra"]<- "Andasibe/Analamazaotra"
tourism_agg$Name[tourism_agg$Name=="Mantadia"]<- "Andasibe/Analamazaotra"
tourism_agg$Name[tourism_agg$Name=="Bemaraha (partie Nord)"]<- "Bemaraha (combined)"
tourism_agg$Name[tourism_agg$Name=="Bemaraha partie Sud"]<- "Bemaraha (combined)"
tourism_agg$Name[tourism_agg$Name=="Tsingy de Namoroka"]<- "Namoroka/Baie de Baly"
tourism_agg$Name[tourism_agg$Name=="Baie de Baly"]<- "Namoroka/Baie de Baly"
tourism_agg$Name[tourism_agg$Name=="Zahamena RNI"]<- "Zahamena" 
tourism_agg$Name[tourism_agg$Name=="Nosy Mangabe"]<- "Masoala"
tourism_agg$Name[tourism_agg$Name=="Foret d'Ambre"]<-  "Montagne d'Ambre" 


deforestation_dat_agg$Year <- as.character(deforestation_dat_agg$Year)

deforestation_dat_agg2 <- full_join(deforestation_dat_agg, tourism_agg, by=c("Name", "Year"))


deforestation_dat_agg2 <- deforestation_dat_agg2 %>% dplyr::group_by(Name, Year) %>% dplyr::summarise(Tourism = sum(Tourism), PercentDeforest_old=mean(PercentDeforest*fc1990),area=mean(fc1990), PercentDeforest=PercentDeforest_old/area) %>% filter(Name!="Sahamalaza", Name!="Mikea")

deforestation_dat_agg2$Tourism[deforestation_dat_agg2$Year==1990]<- NA
deforestation_dat_agg2$Tourism[deforestation_dat_agg2$Year==1991]<- NA

#precipitation

precip_full_1990_1 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_01AllFull.xls")
precip_full_1990_2 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_02AllFull.xls")
precip_full_1990_3 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_03AllFull.xls")
precip_full_1990_4 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_04AllFull.xls")
precip_full_1990_5 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_05AllFull.xls")
precip_full_1990_6 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_06AllFull.xls")
precip_full_1990_7 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_07AllFull.xls")
precip_full_1990_8 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_08AllFull.xls")
precip_full_1990_9 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_09AllFull.xls")
precip_full_1990_10 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_10AllFull.xls")
precip_full_1990_11 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_11AllFull.xls")
precip_full_1990_12 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_12AllFull.xls")
precip_full_1990_1 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_01AllFull.xls")
precip_full_1990_2 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_02AllFull.xls")
precip_full_1990_3 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_03AllFull.xls")
precip_full_1990_4 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_04AllFull.xls")
precip_full_1990_5 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_05AllFull.xls")
precip_full_1990_6 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_06AllFull.xls")
precip_full_1990_7 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_07AllFull.xls")
precip_full_1990_8 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_08AllFull.xls")
precip_full_1990_9 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_09AllFull.xls")
precip_full_1990_10 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_10AllFull.xls")
precip_full_1990_11 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_11AllFull.xls")
precip_full_1990_12 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1990_12AllFull.xls")
precip_full_1991_1 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1991_01AllFull.xls")
precip_full_1991_2 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1991_02AllFull.xls")
precip_full_1991_3 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1991_03AllFull.xls")
precip_full_1991_4 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1991_04AllFull.xls")
precip_full_1991_5 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1991_05AllFull.xls")
precip_full_1991_6 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1991_06AllFull.xls")
precip_full_1991_7 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1991_07AllFull.xls")
precip_full_1991_8 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1991_08AllFull.xls")
precip_full_1991_9 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1991_09AllFull.xls")
precip_full_1991_10 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1991_10AllFull.xls")
precip_full_1991_11 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1991_11AllFull.xls")
precip_full_1991_12 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1991_12AllFull.xls")
precip_full_1992_1 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1992_01AllFull.xls")
precip_full_1992_2 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1992_02AllFull.xls")
precip_full_1992_3 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1992_03AllFull.xls")
precip_full_1992_4 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1992_04AllFull.xls")
precip_full_1992_5 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1992_05AllFull.xls")
precip_full_1992_6 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1992_06AllFull.xls")
precip_full_1992_7 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1992_07AllFull.xls")
precip_full_1992_8 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1992_08AllFull.xls")
precip_full_1992_9 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1992_09AllFull.xls")
precip_full_1992_10 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1992_10AllFull.xls")
precip_full_1992_11 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1992_11AllFull.xls")
precip_full_1992_12 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1992_12AllFull.xls")
precip_full_1993_1 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1993_01AllFull.xls")
precip_full_1993_2 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1993_02AllFull.xls")
precip_full_1993_3 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1993_03AllFull.xls")
precip_full_1993_4 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1993_04AllFull.xls")
precip_full_1993_5 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1993_05AllFull.xls")
precip_full_1993_6 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1993_06AllFull.xls")
precip_full_1993_7 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1993_07AllFull.xls")
precip_full_1993_8 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1993_08AllFull.xls")
precip_full_1993_9 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1993_09AllFull.xls")
precip_full_1993_10 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1993_10AllFull.xls")
precip_full_1993_11 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1993_11AllFull.xls")
precip_full_1993_12 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1993_12AllFull.xls")
precip_full_1994_1 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1994_01AllFull.xls")
precip_full_1994_2 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1994_02AllFull.xls")
precip_full_1994_3 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1994_03AllFull.xls")
precip_full_1994_4 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1994_04AllFull.xls")
precip_full_1994_5 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1994_05AllFull.xls")
precip_full_1994_6 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1994_06AllFull.xls")
precip_full_1994_7 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1994_07AllFull.xls")
precip_full_1994_8 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1994_08AllFull.xls")
precip_full_1994_9 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1994_09AllFull.xls")
precip_full_1994_10 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1994_10AllFull.xls")
precip_full_1994_11 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1994_11AllFull.xls")
precip_full_1994_12 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1994_12AllFull.xls")
precip_full_1995_1 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1995_01AllFull.xls")
precip_full_1995_2 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1995_02AllFull.xls")
precip_full_1995_3 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1995_03AllFull.xls")
precip_full_1995_4 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1995_04AllFull.xls")
precip_full_1995_5 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1995_05AllFull.xls")
precip_full_1995_6 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1995_06AllFull.xls")
precip_full_1995_7 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1995_07AllFull.xls")
precip_full_1995_8 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1995_08AllFull.xls")
precip_full_1995_9 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1995_09AllFull.xls")
precip_full_1995_10 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1995_10AllFull.xls")
precip_full_1995_11 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1995_11AllFull.xls")
precip_full_1995_12 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1995_12AllFull.xls")
precip_full_1996_1 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1996_01AllFull.xls")
precip_full_1996_2 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1996_02AllFull.xls")
precip_full_1996_3 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1996_03AllFull.xls")
precip_full_1996_4 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1996_04AllFull.xls")
precip_full_1996_5 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1996_05AllFull.xls")
precip_full_1996_6 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1996_06AllFull.xls")
precip_full_1996_7 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1996_07AllFull.xls")
precip_full_1996_8 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1996_08AllFull.xls")
precip_full_1996_9 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1996_09AllFull.xls")
precip_full_1996_10 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1996_10AllFull.xls")
precip_full_1996_11 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1996_11AllFull.xls")
precip_full_1996_12 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1996_12AllFull.xls")
precip_full_1997_1 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1997_01AllFull.xls")
precip_full_1997_2 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1997_02AllFull.xls")
precip_full_1997_3 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1997_03AllFull.xls")
precip_full_1997_4 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1997_04AllFull.xls")
precip_full_1997_5 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1997_05AllFull.xls")
precip_full_1997_6 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1997_06AllFull.xls")
precip_full_1997_7 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1997_07AllFull.xls")
precip_full_1997_8 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1997_08AllFull.xls")
precip_full_1997_9 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1997_09AllFull.xls")
precip_full_1997_10 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1997_10AllFull.xls")
precip_full_1997_11 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1997_11AllFull.xls")
precip_full_1997_12 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1997_12AllFull.xls")
precip_full_1998_1 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1998_01AllFull.xls")
precip_full_1998_2 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1998_02AllFull.xls")
precip_full_1998_3 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1998_03AllFull.xls")
precip_full_1998_4 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1998_04AllFull.xls")
precip_full_1998_5 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1998_05AllFull.xls")
precip_full_1998_6 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1998_06AllFull.xls")
precip_full_1998_7 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1998_07AllFull.xls")
precip_full_1998_8 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1998_08AllFull.xls")
precip_full_1998_9 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1998_09AllFull.xls")
precip_full_1998_10 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1998_10AllFull.xls")
precip_full_1998_11 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1998_11AllFull.xls")
precip_full_1998_12 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1998_12AllFull.xls")
precip_full_1999_1 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1999_01AllFull.xls")
precip_full_1999_2 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1999_02AllFull.xls")
precip_full_1999_3 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1999_03AllFull.xls")
precip_full_1999_4 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1999_04AllFull.xls")
precip_full_1999_5 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1999_05AllFull.xls")
precip_full_1999_6 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1999_06AllFull.xls")
precip_full_1999_7 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1999_07AllFull.xls")
precip_full_1999_8 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1999_08AllFull.xls")
precip_full_1999_9 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1999_09AllFull.xls")
precip_full_1999_10 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1999_10AllFull.xls")
precip_full_1999_11 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1999_11AllFull.xls")
precip_full_1999_12 <-read_xls("~/Documents/GitHub/TourismDeforestation/Data/MadaPrecipitation/PrecComm_prec_1999_12AllFull.xls")

precip_full_1990 <- rbind(precip_full_1990_1, precip_full_1990_2,precip_full_1990_3,precip_full_1990_4,precip_full_1990_5,precip_full_1990_6,precip_full_1990_7,precip_full_1990_8,precip_full_1990_9,precip_full_1990_10,precip_full_1990_11,precip_full_1990_12)
precip_full_1990$Year <- 1990

precip_full_1991 <- rbind(precip_full_1991_1, precip_full_1991_2,precip_full_1991_3,precip_full_1991_4,precip_full_1991_5,precip_full_1991_6,precip_full_1991_7,precip_full_1991_8,precip_full_1991_9,precip_full_1991_10,precip_full_1991_11,precip_full_1991_12)
precip_full_1991$Year <- 1991

precip_full_1992 <- rbind(precip_full_1992_1, precip_full_1992_2,precip_full_1992_3,precip_full_1992_4,precip_full_1992_5,precip_full_1992_6,precip_full_1992_7,precip_full_1992_8,precip_full_1992_9,precip_full_1992_10,precip_full_1992_11,precip_full_1992_12)
precip_full_1992$Year <- 1992

precip_full_1993 <- rbind(precip_full_1993_1, precip_full_1993_2,precip_full_1993_3,precip_full_1993_4,precip_full_1993_5,precip_full_1993_6,precip_full_1993_7,precip_full_1993_8,precip_full_1993_9,precip_full_1993_10,precip_full_1993_11,precip_full_1993_12)
precip_full_1993$Year <- 1993

precip_full_1994 <- rbind(precip_full_1994_1, precip_full_1994_2,precip_full_1994_3,precip_full_1994_4,precip_full_1994_5,precip_full_1994_6,precip_full_1994_7,precip_full_1994_8,precip_full_1994_9,precip_full_1994_10,precip_full_1994_11,precip_full_1994_12)
precip_full_1994$Year <- 1994

precip_full_1995 <- rbind(precip_full_1995_1, precip_full_1995_2,precip_full_1995_3,precip_full_1995_4,precip_full_1995_5,precip_full_1995_6,precip_full_1995_7,precip_full_1995_8,precip_full_1995_9,precip_full_1995_10,precip_full_1995_11,precip_full_1995_12)
precip_full_1995$Year <- 1995

precip_full_1996 <- rbind(precip_full_1996_1, precip_full_1996_2,precip_full_1996_3,precip_full_1996_4,precip_full_1996_5,precip_full_1996_6,precip_full_1996_7,precip_full_1996_8,precip_full_1996_9,precip_full_1996_10,precip_full_1996_11,precip_full_1996_12)
precip_full_1996$Year <- 1996

precip_full_1997 <- rbind(precip_full_1997_1, precip_full_1997_2,precip_full_1997_3,precip_full_1997_4,precip_full_1997_5,precip_full_1997_6,precip_full_1997_7,precip_full_1997_8,precip_full_1997_9,precip_full_1997_10,precip_full_1997_11,precip_full_1997_12)
precip_full_1997$Year <- 1997

precip_full_1998 <- rbind(precip_full_1998_1, precip_full_1998_2,precip_full_1998_3,precip_full_1998_4,precip_full_1998_5,precip_full_1998_6,precip_full_1998_7,precip_full_1998_8,precip_full_1998_9,precip_full_1998_10,precip_full_1998_11,precip_full_1998_12)
precip_full_1998$Year <- 1998

precip_full_1999 <- rbind(precip_full_1999_1, precip_full_1999_2,precip_full_1999_3,precip_full_1999_4,precip_full_1999_5,precip_full_1999_6,precip_full_1999_7,precip_full_1999_8,precip_full_1999_9,precip_full_1999_10,precip_full_1999_11,precip_full_1999_12)
precip_full_1999$Year <- 1999

precip_full_90s <- rbind(precip_full_1991,precip_full_1992,precip_full_1993,precip_full_1994,precip_full_1995,precip_full_1996,precip_full_1997,precip_full_1998,precip_full_1999)

precip_full_90s  <- precip_full_90s %>% dplyr::select(Year, NOM, MEAN)%>% rename(Name=NOM, precipitation =MEAN)

precip_full_90s <- left_join(precip_full_90s, area_dat, by="Name")

precip_full_90s$Name[precip_full_90s$Name=="Analamazaotra"]<- "Andasibe/Analamazaotra"
precip_full_90s$Name[precip_full_90s$Name=="Mantadia"]<- "Andasibe/Analamazaotra"
precip_full_90s$Name[precip_full_90s$Name=="Bemaraha (partie Nord)"]<- "Bemaraha (combined)"
precip_full_90s$Name[precip_full_90s$Name=="Bemaraha partie Sud"]<- "Bemaraha (combined)"
precip_full_90s$Name[precip_full_90s$Name=="Tsingy de Namoroka"]<- "Namoroka/Baie de Baly"
precip_full_90s$Name[precip_full_90s$Name=="Baie de Baly"]<- "Namoroka/Baie de Baly"
precip_full_90s$Name[precip_full_90s$Name=="Zahamena RNI"]<- "Zahamena" 
precip_full_90s$Name[precip_full_90s$Name=="Nosy Mangabe"]<- "Masoala"
precip_full_90s$Name[precip_full_90s$Name=="Foret d'Ambre"]<-  "Montagne d'Ambre" 

precip_full1_90s <- precip_full_90s %>% group_by(Name, Year) %>% summarise(precipitation_old=mean(precipitation*area), area=mean(area), precipitation=precipitation_old/area) %>% dplyr::select(Year, Name, precipitation)

precipitation_agg <- rbind(mada_precip2, precip_full1_90s)
write.csv(precipitation_agg, "~/Documents/GitHub/TourismDeforestation/Data/Buffer_Outputs/Precip_buffer_3km/precipitation_agg.csv")



precip_agg2000 <- precipitation_agg %>% filter (Year<=2000) %>% group_by(Name)%>% summarise(precipitation2000 =mean(precipitation))
precip_agg2010 <- precipitation_agg %>% filter (Year<=2010,Year >2000) %>% group_by(Name)%>% summarise(precipitation2010 =mean(precipitation))
precip_agg2020 <- precipitation_agg %>% filter (Year<=2020,Year>2010) %>% group_by(Name)%>% summarise(precipitation2020 =mean(precipitation))

precip_agg <- left_join(precip_agg2000, precip_agg2010, by="Name")

precip_agg <- left_join(precip_agg, precip_agg2020, by="Name")

precip_agg <- precip_agg %>% pivot_longer(cols = precipitation2000:precipitation2020, names_to="Year", values_to="precipitation") 
precip_agg$Year <- gsub("precipitation", "" ,precip_agg$Year)


deforestation_dat_agg3 <- full_join(deforestation_dat_agg2, precip_agg, by=c("Name", "Year"))

PopDensity <- PopDensity_total2 
# Pop density
PopDensity_agg <- PopDensity %>% dplyr::filter (Year== 1990 | Year == 2001 | Year==2011)
PopDensity_agg$Year <- as.character(PopDensity_agg$Year)

PopDensity_agg$Year[PopDensity_agg$Year=="1990"]<-  "2000" 
PopDensity_agg$Year[PopDensity_agg$Year=="2001"]<-  "2010" 
PopDensity_agg$Year[PopDensity_agg$Year=="2011"]<-  "2020" 


# PopDensity_agg2000 <- PopDensity %>% filter (Year<=2000) %>% group_by(Name)%>% summarise(PopDensity2000 =mean(PopDensity))
# PopDensity_agg2010 <- PopDensity %>% filter (Year<=2010,Year >2000) %>% group_by(Name)%>% summarise(PopDensity2010 =mean(PopDensity))
# PopDensity_agg2020 <- PopDensity %>% filter (Year<=2020,Year>2010) %>% group_by(Name)%>% summarise(PopDensity2020 =mean(PopDensity))
# 
# PopDensity_agg <- left_join(PopDensity_agg2000, PopDensity_agg2010, by="Name")
# PopDensity_agg <- left_join(PopDensity_agg, PopDensity_agg2020, by="Name")
# PopDensity_agg <- PopDensity_agg %>% pivot_longer(cols = PopDensity2000:PopDensity2020, names_to="Year", values_to="PopDensity") 
# PopDensity_agg$Year <- gsub("PopDensity", "" ,PopDensity_agg$Year)
# 
# PopDensity_agg$Name[PopDensity_agg$Name=="Nosy Mangabe"] <- "Masoala"
# 
# PopDensity_agg <- PopDensity_agg %>% group_by(Name, Year) %>% summarise(PopDensity=mean(PopDensity))

deforestation_dat_agg4 <- full_join(deforestation_dat_agg3, PopDensity_agg, by=c("Name", "Year"))

write.csv(deforestation_dat_agg4,  "~/Documents/GitHub/TourismDeforestation/Data/aggregate_dat.csv")
```