---
title: "01b_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)
points <- read.csv("~/Documents/GitHub/TourismDeforestation/Data/sampling_points.csv")
points_buffer <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/sampling_points_buffer.xlsx")

```

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


###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_2019_precip <- mada_2019_precip %>% rename(OBJECTID = Rowid, RASTERVALU=VALUE) %>% mutate(InclProb=1)%>% select(OBJECTID, InclProb, RASTERVALU, Year)

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_2020_precip <- mada_2020_precip %>% rename(OBJECTID = Rowid, RASTERVALU=VALUE) %>% mutate(InclProb=1)%>% select(OBJECTID, InclProb, RASTERVALU, Year)

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
mada_2021_precip <- mada_2021_precip %>% rename(OBJECTID = Rowid, RASTERVALU=VALUE) %>% mutate(InclProb=1)%>% select(OBJECTID, InclProb, RASTERVALU, Year)

###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_2019_precip,mada_2020_precip,mada_2021_precip)

mada_precip_new <- mada_precip %>% select(-InclProb) %>% group_by(OBJECTID, Year)%>% summarise(RASTERVALU= mean(RASTERVALU))

mada_precip_points <- left_join(mada_precip_new, points, by="OBJECTID")

#select variables relevant for analysis
mada_precip2 <- mada_precip_points %>%rename(precipitation=RASTERVALU, Name=NOM)%>% dplyr::select(Name, precipitation, Year,  OBJECTID)
#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"

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

```

```{r Population Density Compulation -- Full }
#IMPORT POPULATION DENSITY DATA
PopDensity1990 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/pop1990points_ExportTable_TableToExcel.xlsx")
PopDensity1990$InclProb <- 1
PopDensity1990 <- PopDensity1990 %>% select(OBJECTID, InclProb, RASTERVALU)
PopDensity2000 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2000_1km_UNadjAllFull.xls")
PopDensity2001 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2001_1km_UNadjAllFull.xls")
PopDensity2002 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2002_1km_UNadjAllFull.xls")
PopDensity2003 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2003_1km_UNadjAllFull.xls")
PopDensity2004 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2004_1km_UNadjAllFull.xls")
PopDensity2005 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2005_1km_UNadjAllFull.xls")
PopDensity2006 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2006_1km_UNadjAllFull.xls")
PopDensity2007 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2007_1km_UNadjAllFull.xls")
PopDensity2008 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2008_1km_UNadjAllFull.xls")
PopDensity2009 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2009_1km_UNadjAllFull.xls")
PopDensity2010 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2010_1km_UNadjAllFull.xls")
PopDensity2011 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2011_1km_UNadjAllFull.xls")
PopDensity2012 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2012_1km_UNadjAllFull.xls")
PopDensity2013 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2013_1km_UNadjAllFull.xls")
PopDensity2014 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2014_1km_UNadjAllFull.xls")
PopDensity2015 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2015_1km_UNadjAllFull.xls")
PopDensity2016 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2016_1km_UNadjAllFull.xls")
PopDensity2017 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2017_1km_UNadjAllFull.xls")
PopDensity2018 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2018_1km_UNadjAllFull.xls")
PopDensity2019 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2019_1km_UNadjAllFull.xls")
PopDensity2020 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopPoints_mdg_pd_2020_1km_UNadjAllFull.xls")

#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_new <- left_join(PopDensity_total, points, by="OBJECTID")

#select relevant variables
PopDensity_total2 <- PopDensity_total_new %>% dplyr::select(NOM, RASTERVALU, Year, OBJECTID) %>% dplyr::rename(Name=NOM, PopDensity=RASTERVALU)

#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"

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

```{r Forest loss proportion-- Full}
#read tourism and deforestation data
deforestation_dat1990 <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/forestcover1990p_ExportTable_TableToExcel.xlsx")
deforestation_dat1990$InclProb <- 1
deforestation_dat1990 <- deforestation_dat1990 %>%select(OBJECTID, InclProb, RASTERVALU)
deforestation_dat_agg000 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2000_ProjectRasterAllFull.xls")
deforestation_dat_agg001 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2001_ProjectRasterAllFull.xls")
deforestation_dat_agg002 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2002_ProjectRasterAllFull.xls")
deforestation_dat_agg003 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2003_ProjectRasterAllFull.xls")
deforestation_dat_agg004 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2004_ProjectRasterAllFull.xls")
deforestation_dat_agg005 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2005_ProjectRasterAllFull.xls")
deforestation_dat_agg006 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2006_ProjectRasterAllFull.xls")
deforestation_dat_agg007 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2007_ProjectRasterAllFull.xls")
deforestation_dat_agg008 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2008_ProjectRasterAllFull.xls")
deforestation_dat_agg009 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2009_ProjectRasterAllFull.xls")
deforestation_dat_agg010 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2010_ProjectRasterAllFull.xls")
deforestation_dat_agg011 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2011_ProjectRasterAllFull.xls")
deforestation_dat_agg012 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2012_ProjectRasterAllFull.xls")
deforestation_dat_agg013 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2013_ProjectRasterAllFull.xls")
deforestation_dat_agg014 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2014_ProjectRasterAllFull.xls")
deforestation_dat_agg015 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2015_ProjectRasterAllFull.xls")
deforestation_dat_agg016 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2016_ProjectRasterAllFull.xls")
deforestation_dat_agg017 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2017_ProjectRasterAllFull.xls")
deforestation_dat_agg018 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2018_ProjectRasterAllFull.xls")
deforestation_dat_agg019 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2019_ProjectRasterAllFull.xls")
deforestation_dat_agg020 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2020_ProjectRasterAllFull.xls")
deforestation_dat_agg021 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover//FCPoints_fc90_2021_ProjectRasterAllFull.xls")
deforestation_dat1990$Year <- "fc1990"
deforestation_dat_agg000$Year <- "fc2000"
deforestation_dat_agg001$Year <- "fc2001"
deforestation_dat_agg002$Year <- "fc2002"
deforestation_dat_agg003$Year <- "fc2003"
deforestation_dat_agg004$Year <- "fc2004"
deforestation_dat_agg005$Year <- "fc2005"
deforestation_dat_agg006$Year <- "fc2006"
deforestation_dat_agg007$Year <- "fc2007"
deforestation_dat_agg008$Year <- "fc2008"
deforestation_dat_agg009$Year <- "fc2009"
deforestation_dat_agg010$Year <- "fc2010"
deforestation_dat_agg011$Year <- "fc2011"
deforestation_dat_agg012$Year <- "fc2012"
deforestation_dat_agg013$Year <- "fc2013"
deforestation_dat_agg014$Year <- "fc2014"
deforestation_dat_agg015$Year <- "fc2015"
deforestation_dat_agg016$Year <- "fc2016"
deforestation_dat_agg017$Year <- "fc2017"
deforestation_dat_agg018$Year <- "fc2018"
deforestation_dat_agg019$Year <- "fc2019"
deforestation_dat_agg020$Year <- "fc2020"
deforestation_dat_agg021$Year <- "fc2021"
deforestation_dat_agg000$Year <- "fc2000"

deforestation_dat <- rbind(deforestation_dat1990,deforestation_dat_agg000, deforestation_dat_agg001, deforestation_dat_agg002, deforestation_dat_agg003, deforestation_dat_agg004, deforestation_dat_agg005, deforestation_dat_agg006, deforestation_dat_agg007, deforestation_dat_agg008, deforestation_dat_agg009, deforestation_dat_agg010, deforestation_dat_agg011, deforestation_dat_agg012, deforestation_dat_agg013, deforestation_dat_agg014, deforestation_dat_agg015, deforestation_dat_agg016, deforestation_dat_agg017, deforestation_dat_agg018, deforestation_dat_agg019, deforestation_dat_agg020, deforestation_dat_agg021)

deforestation_dat_new <- left_join(deforestation_dat, points, by="OBJECTID")

deforestation_dat_agg <- deforestation_dat_new %>% select(NOM, RASTERVALU, Year, OBJECTID)%>%rename(SUM=RASTERVALU) %>% pivot_wider(names_from = "Year", values_from= "SUM")

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

#manually fix some data errors
deforestation_dat_agg$fc2000[deforestation_dat_agg$fc2000>1000] <- 0
deforestation_dat_agg$fc2000[deforestation_dat_agg$fc2000< -1000] <- 0
deforestation_dat_agg$fc2010[deforestation_dat_agg$fc2010>1000] <- 0
deforestation_dat_agg$fc2010[deforestation_dat_agg$fc2010< -1000] <- 0
deforestation_dat_agg$fc2011[deforestation_dat_agg$fc2011>1000] <- 0
deforestation_dat_agg$fc2011[deforestation_dat_agg$fc2011< -1000] <- 0

deforestation_dat3 <- deforestation_dat_agg %>% select(OBJECTID,NOM, flp2001:flp2021) 
deforestation_dat3$OBJECTID <- as.character(deforestation_dat3$OBJECTID)
deforestation_dat3 <- deforestation_dat3%>% 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)


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" 


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

```

```{r Precipitation Compilation-- Buffer}
###IMPORT   MONTHLY PRECIPITATION DATA
#2000
mada_2000_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2000_01Buffer.xls")
mada_2000_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2000_02Buffer.xls")
mada_2000_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2000_03Buffer.xls")
mada_2000_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2000_04Buffer.xls")
mada_2000_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2000_05Buffer.xls")
mada_2000_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2000_06Buffer.xls")
mada_2000_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2000_07Buffer.xls")
mada_2000_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2000_08Buffer.xls")
mada_2000_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2000_09Buffer.xls")
mada_2000_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2000_10Buffer.xls")
mada_2000_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2000_11Buffer.xls")
mada_2000_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2000_12Buffer.xls")
#2001
mada_2001_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2001_01Buffer.xls")
mada_2001_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2001_02Buffer.xls")
mada_2001_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2001_03Buffer.xls")
mada_2001_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2001_04Buffer.xls")
mada_2001_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2001_05Buffer.xls")
mada_2001_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2001_06Buffer.xls")
mada_2001_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2001_07Buffer.xls")
mada_2001_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2001_08Buffer.xls")
mada_2001_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2001_09Buffer.xls")
mada_2001_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2001_10Buffer.xls")
mada_2001_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2001_11Buffer.xls")
mada_2001_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2001_12Buffer.xls")
#2002
mada_2002_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2002_01Buffer.xls")
mada_2002_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2002_02Buffer.xls")
mada_2002_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2002_03Buffer.xls")
mada_2002_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2002_04Buffer.xls")
mada_2002_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2002_05Buffer.xls")
mada_2002_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2002_06Buffer.xls")
mada_2002_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2002_07Buffer.xls")
mada_2002_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2002_08Buffer.xls")
mada_2002_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2002_09Buffer.xls")
mada_2002_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2002_10Buffer.xls")
mada_2002_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2002_11Buffer.xls")
mada_2002_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2002_12Buffer.xls")
#2003
mada_2003_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2003_01Buffer.xls")
mada_2003_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2003_02Buffer.xls")
mada_2003_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2003_03Buffer.xls")
mada_2003_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2003_04Buffer.xls")
mada_2003_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2003_05Buffer.xls")
mada_2003_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2003_06Buffer.xls")
mada_2003_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2003_07Buffer.xls")
mada_2003_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2003_08Buffer.xls")
mada_2003_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2003_09Buffer.xls")
mada_2003_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2003_10Buffer.xls")
mada_2003_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2003_11Buffer.xls")
mada_2003_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2003_12Buffer.xls")
#2004
mada_2004_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2004_01Buffer.xls")
mada_2004_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2004_02Buffer.xls")
mada_2004_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2004_03Buffer.xls")
mada_2004_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2004_04Buffer.xls")
mada_2004_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2004_05Buffer.xls")
mada_2004_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2004_06Buffer.xls")
mada_2004_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2004_07Buffer.xls")
mada_2004_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2004_08Buffer.xls")
mada_2004_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2004_09Buffer.xls")
mada_2004_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2004_10Buffer.xls")
mada_2004_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2004_11Buffer.xls")
mada_2004_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2004_12Buffer.xls")
#2005
mada_2005_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2005_01Buffer.xls")
mada_2005_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2005_02Buffer.xls")
mada_2005_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2005_03Buffer.xls")
mada_2005_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2005_04Buffer.xls")
mada_2005_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2005_05Buffer.xls")
mada_2005_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2005_06Buffer.xls")
mada_2005_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2005_07Buffer.xls")
mada_2005_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2005_08Buffer.xls")
mada_2005_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2005_09Buffer.xls")
mada_2005_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2005_10Buffer.xls")
mada_2005_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2005_11Buffer.xls")
mada_2005_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2005_12Buffer.xls")
#2006
mada_2006_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2006_01Buffer.xls")
mada_2006_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2006_02Buffer.xls")
mada_2006_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2006_03Buffer.xls")
mada_2006_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2006_04Buffer.xls")
mada_2006_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2006_05Buffer.xls")
mada_2006_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2006_06Buffer.xls")
mada_2006_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2006_07Buffer.xls")
mada_2006_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2006_08Buffer.xls")
mada_2006_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2006_09Buffer.xls")
mada_2006_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2006_10Buffer.xls")
mada_2006_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2006_11Buffer.xls")
mada_2006_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2006_12Buffer.xls")
#2007
mada_2007_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2007_01Buffer.xls")
mada_2007_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2007_02Buffer.xls")
mada_2007_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2007_03Buffer.xls")
mada_2007_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2007_04Buffer.xls")
mada_2007_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2007_05Buffer.xls")
mada_2007_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2007_06Buffer.xls")
mada_2007_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2007_07Buffer.xls")
mada_2007_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2007_08Buffer.xls")
mada_2007_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2007_09Buffer.xls")
mada_2007_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2007_10Buffer.xls")
mada_2007_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2007_11Buffer.xls")
mada_2007_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2007_12Buffer.xls")
#2008
mada_2008_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2008_01Buffer.xls")
mada_2008_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2008_02Buffer.xls")
mada_2008_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2008_03Buffer.xls")
mada_2008_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2008_04Buffer.xls")
mada_2008_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2008_05Buffer.xls")
mada_2008_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2008_06Buffer.xls")
mada_2008_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2008_07Buffer.xls")
mada_2008_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2008_08Buffer.xls")
mada_2008_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2008_09Buffer.xls")
mada_2008_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2008_10Buffer.xls")
mada_2008_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2008_11Buffer.xls")
mada_2008_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2008_12Buffer.xls")
#2009
mada_2009_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2009_01Buffer.xls")
mada_2009_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2009_02Buffer.xls")
mada_2009_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2009_03Buffer.xls")
mada_2009_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2009_04Buffer.xls")
mada_2009_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2009_05Buffer.xls")
mada_2009_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2009_06Buffer.xls")
mada_2009_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2009_07Buffer.xls")
mada_2009_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2009_08Buffer.xls")
mada_2009_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2009_09Buffer.xls")
mada_2009_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2009_10Buffer.xls")
mada_2009_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2009_11Buffer.xls")
mada_2009_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2009_12Buffer.xls")
#2010
mada_2010_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2010_01Buffer.xls")
mada_2010_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2010_02Buffer.xls")
mada_2010_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2010_03Buffer.xls")
mada_2010_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2010_04Buffer.xls")
mada_2010_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2010_05Buffer.xls")
mada_2010_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2010_06Buffer.xls")
mada_2010_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2010_07Buffer.xls")
mada_2010_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2010_08Buffer.xls")
mada_2010_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2010_09Buffer.xls")
mada_2010_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2010_10Buffer.xls")
mada_2010_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2010_11Buffer.xls")
mada_2010_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2010_12Buffer.xls")
#2011
mada_2011_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2011_01Buffer.xls")
mada_2011_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2011_02Buffer.xls")
mada_2011_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2011_03Buffer.xls")
mada_2011_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2011_04Buffer.xls")
mada_2011_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2011_05Buffer.xls")
mada_2011_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2011_06Buffer.xls")
mada_2011_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2011_07Buffer.xls")
mada_2011_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2011_08Buffer.xls")
mada_2011_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2011_09Buffer.xls")
mada_2011_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2011_10Buffer.xls")
mada_2011_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2011_11Buffer.xls")
mada_2011_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2011_12Buffer.xls")
#2012
mada_2012_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2012_01Buffer.xls")
mada_2012_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2012_02Buffer.xls")
mada_2012_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2012_03Buffer.xls")
mada_2012_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2012_04Buffer.xls")
mada_2012_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2012_05Buffer.xls")
mada_2012_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2012_06Buffer.xls")
mada_2012_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2012_07Buffer.xls")
mada_2012_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2012_08Buffer.xls")
mada_2012_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2012_09Buffer.xls")
mada_2012_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2012_10Buffer.xls")
mada_2012_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2012_11Buffer.xls")
mada_2012_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2012_12Buffer.xls")
#2013
mada_2013_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2013_01Buffer.xls")
mada_2013_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2013_02Buffer.xls")
mada_2013_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2013_03Buffer.xls")
mada_2013_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2013_04Buffer.xls")
mada_2013_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2013_05Buffer.xls")
mada_2013_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2013_06Buffer.xls")
mada_2013_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2013_07Buffer.xls")
mada_2013_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2013_08Buffer.xls")
mada_2013_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2013_09Buffer.xls")
mada_2013_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2013_10Buffer.xls")
mada_2013_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2013_11Buffer.xls")
mada_2013_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2013_12Buffer.xls")
#2014
mada_2014_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2014_01Buffer.xls")
mada_2014_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2014_02Buffer.xls")
mada_2014_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2014_03Buffer.xls")
mada_2014_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2014_04Buffer.xls")
mada_2014_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2014_05Buffer.xls")
mada_2014_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2014_06Buffer.xls")
mada_2014_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2014_07Buffer.xls")
mada_2014_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2014_08Buffer.xls")
mada_2014_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2014_09Buffer.xls")
mada_2014_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2014_10Buffer.xls")
mada_2014_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2014_11Buffer.xls")
mada_2014_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2014_12Buffer.xls")
#2015
mada_2015_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2015_01Buffer.xls")
mada_2015_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2015_02Buffer.xls")
mada_2015_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2015_03Buffer.xls")
mada_2015_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2015_04Buffer.xls")
mada_2015_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2015_05Buffer.xls")
mada_2015_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2015_06Buffer.xls")
mada_2015_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2015_07Buffer.xls")
mada_2015_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2015_08Buffer.xls")
mada_2015_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2015_09Buffer.xls")
mada_2015_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2015_10Buffer.xls")
mada_2015_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2015_11Buffer.xls")
mada_2015_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2015_12Buffer.xls")
#2016
mada_2016_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2016_01Buffer.xls")
mada_2016_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2016_02Buffer.xls")
mada_2016_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2016_03Buffer.xls")
mada_2016_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2016_04Buffer.xls")
mada_2016_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2016_05Buffer.xls")
mada_2016_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2016_06Buffer.xls")
mada_2016_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2016_07Buffer.xls")
mada_2016_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2016_08Buffer.xls")
mada_2016_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2016_09Buffer.xls")
mada_2016_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2016_10Buffer.xls")
mada_2016_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2016_11Buffer.xls")
mada_2016_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2016_12Buffer.xls")
#2017
mada_2017_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2017_01Buffer.xls")
mada_2017_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2017_02Buffer.xls")
mada_2017_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2017_03Buffer.xls")
mada_2017_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2017_04Buffer.xls")
mada_2017_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2017_05Buffer.xls")
mada_2017_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2017_06Buffer.xls")
mada_2017_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2017_07Buffer.xls")
mada_2017_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2017_08Buffer.xls")
mada_2017_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2017_09Buffer.xls")
mada_2017_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2017_10Buffer.xls")
mada_2017_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2017_11Buffer.xls")
mada_2017_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2017_12Buffer.xls")
#2018
mada_2018_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2018_01Buffer.xls")
mada_2018_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2018_02Buffer.xls")
mada_2018_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2018_03Buffer.xls")
mada_2018_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2018_04Buffer.xls")
mada_2018_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2018_05Buffer.xls")
mada_2018_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2018_06Buffer.xls")
mada_2018_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2018_07Buffer.xls")
mada_2018_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2018_08Buffer.xls")
mada_2018_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2018_09Buffer.xls")
mada_2018_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2018_10Buffer.xls")
mada_2018_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2018_11Buffer.xls")
mada_2018_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/Buffer_precpoints_prec_2018_12Buffer.xls")
#2019
mada_2019_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints201901.xls")
mada_2019_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints201902.xls")
mada_2019_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints201903.xls")
mada_2019_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints201904.xls")
mada_2019_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints201905.xls")
mada_2019_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints201906.xls")
mada_2019_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints201907.xls")
mada_2019_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints201908.xls")
mada_2019_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints201909.xls")
mada_2019_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints201910.xls")
mada_2019_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints201911.xls")
mada_2019_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints201912.xls")
#2020
mada_2020_1_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202001.xls")
mada_2020_2_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202002.xls")
mada_2020_3_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202003.xls")
mada_2020_4_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202004.xls")
mada_2020_5_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202005.xls")
mada_2020_6_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202006.xls")
mada_2020_7_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202007.xls")
mada_2020_8_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202008.xls")
mada_2020_9_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202009.xls")
mada_2020_10_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202010.xls")
mada_2020_11_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202011.xls")
mada_2020_12_precip_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202012.xls")
#2021
mada_2021_1_precip_buffer <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202101.xlsx")
mada_2021_2_precip_buffer <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202102.xlsx")
mada_2021_3_precip_buffer <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202103.xlsx")
mada_2021_4_precip_buffer <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202104.xlsx")
mada_2021_5_precip_buffer <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202105.xlsx")
mada_2021_6_precip_buffer <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202106.xlsx")
mada_2021_7_precip_buffer <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202107.xlsx")
mada_2021_8_precip_buffer <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202108.xlsx")
mada_2021_9_precip_buffer <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202109.xlsx")
mada_2021_10_precip_buffer <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202110.xlsx")
mada_2021_11_precip_buffer <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202111.xlsx")
mada_2021_12_precip_buffer <- read_xlsx("~/Documents/GitHub/TourismDeforestation/Data/precipitation/precpoints202112.xlsx")


###COMPILE MONTHLY PRECIPITATION DATA BY YEAR 
mada_2000_precip_buffer <- rbind(mada_2000_1_precip_buffer, mada_2000_2_precip_buffer, mada_2000_3_precip_buffer, mada_2000_4_precip_buffer, mada_2000_5_precip_buffer, mada_2000_6_precip_buffer, mada_2000_7_precip_buffer, mada_2000_8_precip_buffer, mada_2000_9_precip_buffer, mada_2000_10_precip_buffer, mada_2000_11_precip_buffer, mada_2000_12_precip_buffer)
mada_2000_precip_buffer$Year <- 2000


mada_2001_precip_buffer <- rbind(mada_2001_1_precip_buffer, mada_2001_2_precip_buffer, mada_2001_3_precip_buffer, mada_2001_4_precip_buffer, mada_2001_5_precip_buffer, mada_2001_6_precip_buffer, mada_2001_7_precip_buffer, mada_2001_8_precip_buffer, mada_2001_9_precip_buffer, mada_2001_10_precip_buffer, mada_2001_11_precip_buffer, mada_2001_12_precip_buffer)
mada_2001_precip_buffer$Year <- 2001

mada_2002_precip_buffer <- rbind(mada_2002_1_precip_buffer, mada_2002_2_precip_buffer, mada_2002_3_precip_buffer, mada_2002_4_precip_buffer, mada_2002_5_precip_buffer, mada_2002_6_precip_buffer, mada_2002_7_precip_buffer, mada_2002_8_precip_buffer, mada_2002_9_precip_buffer, mada_2002_10_precip_buffer, mada_2002_11_precip_buffer, mada_2002_12_precip_buffer)
mada_2002_precip_buffer$Year <- 2002

mada_2003_precip_buffer <- rbind(mada_2003_1_precip_buffer, mada_2003_2_precip_buffer, mada_2003_3_precip_buffer, mada_2003_4_precip_buffer, mada_2003_5_precip_buffer, mada_2003_6_precip_buffer, mada_2003_7_precip_buffer, mada_2003_8_precip_buffer, mada_2003_9_precip_buffer, mada_2003_10_precip_buffer, mada_2003_11_precip_buffer, mada_2003_12_precip_buffer)
mada_2003_precip_buffer$Year <- 2003

mada_2004_precip_buffer <- rbind(mada_2004_1_precip_buffer, mada_2004_2_precip_buffer, mada_2004_3_precip_buffer, mada_2004_4_precip_buffer,  mada_2004_6_precip_buffer, mada_2004_7_precip_buffer, mada_2004_8_precip_buffer, mada_2004_9_precip_buffer, mada_2004_10_precip_buffer, mada_2004_11_precip_buffer, mada_2004_12_precip_buffer)
mada_2004_precip_buffer$Year <- 2004

mada_2005_precip_buffer <- rbind(mada_2005_1_precip_buffer, mada_2005_2_precip_buffer, mada_2005_3_precip_buffer, mada_2005_4_precip_buffer, mada_2005_5_precip_buffer, mada_2005_6_precip_buffer, mada_2005_7_precip_buffer, mada_2005_8_precip_buffer, mada_2005_9_precip_buffer, mada_2005_10_precip_buffer, mada_2005_11_precip_buffer, mada_2005_12_precip_buffer)
mada_2005_precip_buffer$Year <- 2005

mada_2006_precip_buffer <- rbind(mada_2006_1_precip_buffer, mada_2006_2_precip_buffer, mada_2006_3_precip_buffer, mada_2006_4_precip_buffer, mada_2006_5_precip_buffer, mada_2006_6_precip_buffer, mada_2006_7_precip_buffer, mada_2006_8_precip_buffer, mada_2006_9_precip_buffer, mada_2006_10_precip_buffer, mada_2006_11_precip_buffer, mada_2006_12_precip_buffer)
mada_2006_precip_buffer$Year <- 2006

mada_2007_precip_buffer <- rbind(mada_2007_1_precip_buffer, mada_2007_2_precip_buffer, mada_2007_3_precip_buffer, mada_2007_4_precip_buffer, mada_2007_5_precip_buffer, mada_2007_6_precip_buffer, mada_2007_8_precip_buffer, mada_2007_9_precip_buffer, mada_2007_10_precip_buffer, mada_2007_11_precip_buffer, mada_2007_12_precip_buffer)
mada_2007_precip_buffer$Year <- 2007

mada_2008_precip_buffer <- rbind(mada_2008_1_precip_buffer, mada_2008_2_precip_buffer, mada_2008_3_precip_buffer, mada_2008_4_precip_buffer, mada_2008_5_precip_buffer, mada_2008_6_precip_buffer, mada_2008_7_precip_buffer, mada_2008_8_precip_buffer, mada_2008_9_precip_buffer, mada_2008_10_precip_buffer, mada_2008_11_precip_buffer, mada_2008_12_precip_buffer)
mada_2008_precip_buffer$Year <- 2008

mada_2009_precip_buffer <- rbind(mada_2009_1_precip_buffer, mada_2009_2_precip_buffer, mada_2009_3_precip_buffer, mada_2009_4_precip_buffer, mada_2009_5_precip_buffer, mada_2009_6_precip_buffer, mada_2009_7_precip_buffer, mada_2009_8_precip_buffer, mada_2009_9_precip_buffer, mada_2009_10_precip_buffer, mada_2009_11_precip_buffer, mada_2009_12_precip_buffer)
mada_2009_precip_buffer$Year <- 2009

mada_2010_precip_buffer <- rbind(mada_2010_1_precip_buffer, mada_2010_2_precip_buffer, mada_2010_3_precip_buffer, mada_2010_4_precip_buffer, mada_2010_5_precip_buffer, mada_2010_6_precip_buffer, mada_2010_7_precip_buffer, mada_2010_8_precip_buffer, mada_2010_9_precip_buffer, mada_2010_10_precip_buffer, mada_2010_11_precip_buffer, mada_2010_12_precip_buffer)
mada_2010_precip_buffer$Year <- 2010

mada_2011_precip_buffer <- rbind(mada_2011_1_precip_buffer, mada_2011_2_precip_buffer, mada_2011_3_precip_buffer, mada_2011_4_precip_buffer, mada_2011_5_precip_buffer, mada_2011_6_precip_buffer, mada_2011_7_precip_buffer, mada_2011_8_precip_buffer, mada_2011_9_precip_buffer, mada_2011_10_precip_buffer, mada_2011_11_precip_buffer, mada_2011_12_precip_buffer)
mada_2011_precip_buffer$Year <- 2011

mada_2012_precip_buffer <- rbind(mada_2012_1_precip_buffer, mada_2012_2_precip_buffer, mada_2012_3_precip_buffer, mada_2012_4_precip_buffer, mada_2012_5_precip_buffer, mada_2012_6_precip_buffer, mada_2012_7_precip_buffer, mada_2012_8_precip_buffer, mada_2012_9_precip_buffer, mada_2012_10_precip_buffer, mada_2012_11_precip_buffer, mada_2012_12_precip_buffer)
mada_2012_precip_buffer$Year <- 2012

mada_2013_precip_buffer <- rbind(mada_2013_1_precip_buffer, mada_2013_2_precip_buffer, mada_2013_3_precip_buffer, mada_2013_4_precip_buffer, mada_2013_5_precip_buffer, mada_2013_6_precip_buffer, mada_2013_7_precip_buffer, mada_2013_8_precip_buffer, mada_2013_9_precip_buffer, mada_2013_10_precip_buffer, mada_2013_11_precip_buffer, mada_2013_12_precip_buffer)
mada_2013_precip_buffer$Year <- 2013

mada_2014_precip_buffer <- rbind(mada_2014_1_precip_buffer, mada_2014_2_precip_buffer, mada_2014_3_precip_buffer, mada_2014_4_precip_buffer, mada_2014_5_precip_buffer, mada_2014_6_precip_buffer, mada_2014_7_precip_buffer, mada_2014_8_precip_buffer, mada_2014_9_precip_buffer, mada_2014_10_precip_buffer, mada_2014_11_precip_buffer, mada_2014_12_precip_buffer)
mada_2014_precip_buffer$Year <- 2014

mada_2015_precip_buffer <- rbind(mada_2015_1_precip_buffer, mada_2015_2_precip_buffer, mada_2015_3_precip_buffer, mada_2015_4_precip_buffer, mada_2015_5_precip_buffer, mada_2015_6_precip_buffer, mada_2015_7_precip_buffer, mada_2015_8_precip_buffer, mada_2015_9_precip_buffer, mada_2015_10_precip_buffer, mada_2015_11_precip_buffer, mada_2015_12_precip_buffer)
mada_2015_precip_buffer$Year <- 2015

mada_2016_precip_buffer <- rbind(mada_2016_1_precip_buffer, mada_2016_2_precip_buffer, mada_2016_3_precip_buffer, mada_2016_4_precip_buffer, mada_2016_5_precip_buffer, mada_2016_6_precip_buffer, mada_2016_7_precip_buffer, mada_2016_8_precip_buffer, mada_2016_9_precip_buffer, mada_2016_10_precip_buffer, mada_2016_11_precip_buffer)
mada_2016_precip_buffer$Year <- 2016

mada_2017_precip_buffer <- rbind(mada_2017_1_precip_buffer, mada_2017_2_precip_buffer, mada_2017_3_precip_buffer, mada_2017_4_precip_buffer, mada_2017_5_precip_buffer, mada_2017_6_precip_buffer, mada_2017_7_precip_buffer, mada_2017_8_precip_buffer, mada_2017_9_precip_buffer, mada_2017_10_precip_buffer, mada_2017_11_precip_buffer, mada_2017_12_precip_buffer)
mada_2017_precip_buffer$Year <- 2017

mada_2018_precip_buffer <- rbind(mada_2018_1_precip_buffer, mada_2018_2_precip_buffer, mada_2018_3_precip_buffer, mada_2018_4_precip_buffer, mada_2018_5_precip_buffer, mada_2018_6_precip_buffer, mada_2018_7_precip_buffer, mada_2018_8_precip_buffer, mada_2018_9_precip_buffer, mada_2018_10_precip_buffer, mada_2018_11_precip_buffer, mada_2018_12_precip_buffer)
mada_2018_precip_buffer$Year <- 2018

mada_2019_precip_buffer <- rbind(mada_2019_1_precip_buffer, mada_2019_2_precip_buffer, mada_2019_3_precip_buffer, mada_2019_4_precip_buffer, mada_2019_5_precip_buffer, mada_2019_6_precip_buffer, mada_2019_7_precip_buffer, mada_2019_8_precip_buffer, mada_2019_9_precip_buffer, mada_2019_10_precip_buffer, mada_2019_11_precip_buffer, mada_2019_12_precip_buffer)
mada_2019_precip_buffer$Year <- 2019
mada_2019_precip_buffer <- mada_2019_precip_buffer %>% rename(OBJECTID = Rowid, RASTERVALU=VALUE) %>% mutate(InclProb=1)%>% select(OBJECTID, InclProb, RASTERVALU, Year)

mada_2020_precip_buffer <- rbind(mada_2020_1_precip_buffer, mada_2020_2_precip_buffer, mada_2020_3_precip_buffer, mada_2020_4_precip_buffer, mada_2020_5_precip_buffer, mada_2020_6_precip_buffer, mada_2020_7_precip_buffer, mada_2020_8_precip_buffer, mada_2020_9_precip_buffer, mada_2020_10_precip_buffer, mada_2020_11_precip_buffer, mada_2020_12_precip_buffer)
mada_2020_precip_buffer$Year <- 2020
mada_2020_precip_buffer <- mada_2020_precip_buffer %>% rename(OBJECTID = Rowid, RASTERVALU=VALUE) %>% mutate(InclProb=1)%>% select(OBJECTID, InclProb, RASTERVALU, Year)

mada_2021_precip_buffer <- rbind(mada_2021_1_precip_buffer, mada_2021_2_precip_buffer, mada_2021_3_precip_buffer, mada_2021_4_precip_buffer, mada_2021_5_precip_buffer, mada_2021_6_precip_buffer, mada_2021_7_precip_buffer, mada_2021_8_precip_buffer, mada_2021_9_precip_buffer, mada_2021_10_precip_buffer, mada_2021_11_precip_buffer, mada_2021_12_precip_buffer)
mada_2021_precip_buffer$Year <- 2021
mada_2021_precip_buffer <- mada_2021_precip_buffer %>% rename(OBJECTID = Rowid, RASTERVALU=VALUE) %>% mutate(InclProb=1)%>% select(OBJECTID, InclProb, RASTERVALU, Year)

###COMBINE ALL YEARS INTO ONE DATA FRAME
mada_precip_buffer <- rbind(mada_2000_precip_buffer, mada_2001_precip_buffer, mada_2002_precip_buffer, mada_2003_precip_buffer, mada_2004_precip_buffer, mada_2005_precip_buffer, mada_2006_precip_buffer, mada_2007_precip_buffer, mada_2008_precip_buffer, mada_2009_precip_buffer, mada_2010_precip_buffer, mada_2011_precip_buffer, mada_2012_precip_buffer, mada_2013_precip_buffer, mada_2014_precip_buffer, mada_2015_precip_buffer, mada_2016_precip_buffer, mada_2017_precip_buffer,mada_2018_precip_buffer, mada_2019_precip_buffer,mada_2020_precip_buffer,mada_2021_precip_buffer)

mada_precip_buffer_new <- mada_precip_buffer %>% select(-InclProb) %>% group_by(OBJECTID, Year)%>% summarise(RASTERVALU= mean(RASTERVALU))

mada_precip_buffer_points <- left_join(mada_precip_buffer_new, points_buffer, by="OBJECTID")

#select variables relevant for analysis
mada_precip_buffer2 <- mada_precip_buffer_points %>%rename(precipitation=RASTERVALU, Name=NOM)%>% dplyr::select(Name, precipitation, Year,  OBJECTID)
#check for missing clues 
mada_precip_buffer2[is.na(mada_precip_buffer2$precipitation),]
#no missing precipitation values 

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

write.csv(mada_precip_buffer2, "~/Documents/GitHub/TourismDeforestation/Data/CleanedConfounders/precipitation_points_buffer.csv")

```

```{r Population Density Compulation -- Buffer}
#IMPORT POPULATION DENSITY DATA
PopDensity2000_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2000_1km_UNadjBuffer.xls")
PopDensity2001_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2001_1km_UNadjBuffer.xls")
PopDensity2002_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2002_1km_UNadjBuffer.xls")
PopDensity2003_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2003_1km_UNadjBuffer.xls")
PopDensity2004_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2004_1km_UNadjBuffer.xls")
PopDensity2005_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2005_1km_UNadjBuffer.xls")
PopDensity2006_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2006_1km_UNadjBuffer.xls")
PopDensity2007_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2007_1km_UNadjBuffer.xls")
PopDensity2008_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2008_1km_UNadjBuffer.xls")
PopDensity2009_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2009_1km_UNadjBuffer.xls")
PopDensity2010_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2010_1km_UNadjBuffer.xls")
PopDensity2011_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2011_1km_UNadjBuffer.xls")
PopDensity2012_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2012_1km_UNadjBuffer.xls")
PopDensity2013_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2013_1km_UNadjBuffer.xls")
PopDensity2014_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2014_1km_UNadjBuffer.xls")
PopDensity2015_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2015_1km_UNadjBuffer.xls")
PopDensity2016_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2016_1km_UNadjBuffer.xls")
PopDensity2017_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2017_1km_UNadjBuffer.xls")
PopDensity2018_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2018_1km_UNadjBuffer.xls")
PopDensity2019_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2019_1km_UNadjBuffer.xls")
PopDensity2020_buffer <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/PopDensity/PopDensity_mdg_pd_2020_1km_UNadjBuffer.xls")

#fix "year" variables
PopDensity2000_buffer$Year <- 2001
PopDensity2001_buffer$Year <- 2002
PopDensity2002_buffer$Year <- 2003
PopDensity2003_buffer$Year <- 2004
PopDensity2004_buffer$Year <- 2005
PopDensity2005_buffer$Year <- 2006
PopDensity2006_buffer$Year <- 2007
PopDensity2007_buffer$Year <- 2008
PopDensity2008_buffer$Year <- 2009
PopDensity2009_buffer$Year <- 2010
PopDensity2010_buffer$Year <- 2011
PopDensity2011_buffer$Year <- 2012
PopDensity2012_buffer$Year <- 2013
PopDensity2013_buffer$Year <- 2014
PopDensity2014_buffer$Year <- 2015
PopDensity2015_buffer$Year <- 2016
PopDensity2016_buffer$Year <- 2017
PopDensity2017_buffer$Year <- 2018
PopDensity2018_buffer$Year <- 2019
PopDensity2019_buffer$Year <- 2020
PopDensity2020_buffer$Year <- 2021

#combine all years into one dataframe
PopDensity_total_buffer <- rbind(
                          PopDensity2000_buffer, 
                          PopDensity2001_buffer,
                          PopDensity2002_buffer,
                          PopDensity2003_buffer,
                          PopDensity2004_buffer,
                          PopDensity2005_buffer,
                          PopDensity2006_buffer,
                          PopDensity2007_buffer,
                          PopDensity2008_buffer,
                          PopDensity2009_buffer,
                          PopDensity2010_buffer,
                          PopDensity2011_buffer,
                          PopDensity2012_buffer,
                          PopDensity2013_buffer,
                          PopDensity2014_buffer,
                          PopDensity2015_buffer,
                          PopDensity2016_buffer,
                          PopDensity2017_buffer,
                          PopDensity2018_buffer,
                          PopDensity2019_buffer,
                          PopDensity2020_buffer)

PopDensity_total_new_buffer <- left_join(PopDensity_total_buffer, points_buffer, by="OBJECTID")

#select relevant variables
PopDensity_total2_buffer <- PopDensity_total_new_buffer %>% dplyr::select(NOM, RASTERVALU, Year, OBJECTID) %>% dplyr::rename(Name=NOM, PopDensity=RASTERVALU)

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

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

```{r Forest loss proportion-- Buffer}
#read tourism and deforestation data
deforestation_dat_buffer000 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2000Buffer.xls")
deforestation_dat_buffer001 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2001Buffer.xls")
deforestation_dat_buffer002 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2002Buffer.xls")
deforestation_dat_buffer003 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2003Buffer.xls")
deforestation_dat_buffer004 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2004Buffer.xls")
deforestation_dat_buffer005 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2005Buffer.xls")
deforestation_dat_buffer006 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2006Buffer.xls")
deforestation_dat_buffer007 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2007Buffer.xls")
deforestation_dat_buffer008 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2008Buffer.xls")
deforestation_dat_buffer009 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2009Buffer.xls")
deforestation_dat_buffer010 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2010Buffer.xls")
deforestation_dat_buffer011 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2011Buffer.xls")
deforestation_dat_buffer012 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2012Buffer.xls")
deforestation_dat_buffer013 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2013Buffer.xls")
deforestation_dat_buffer014 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2014Buffer.xls")
deforestation_dat_buffer015 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2015Buffer.xls")
deforestation_dat_buffer016 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2016Buffer.xls")
deforestation_dat_buffer017 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2017Buffer.xls")
deforestation_dat_buffer018 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2018Buffer.xls")
deforestation_dat_buffer019 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2019Buffer.xls")
deforestation_dat_buffer020 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2020Buffer.xls")
deforestation_dat_buffer021 <- read_xls("~/Documents/GitHub/TourismDeforestation/Data/fores_cover/ForestCover_fc90_2021Buffer.xls")

deforestation_dat_buffer000$Year <- "fc2000"
deforestation_dat_buffer001$Year <- "fc2001"
deforestation_dat_buffer002$Year <- "fc2002"
deforestation_dat_buffer003$Year <- "fc2003"
deforestation_dat_buffer004$Year <- "fc2004"
deforestation_dat_buffer005$Year <- "fc2005"
deforestation_dat_buffer006$Year <- "fc2006"
deforestation_dat_buffer007$Year <- "fc2007"
deforestation_dat_buffer008$Year <- "fc2008"
deforestation_dat_buffer009$Year <- "fc2009"
deforestation_dat_buffer010$Year <- "fc2010"
deforestation_dat_buffer011$Year <- "fc2011"
deforestation_dat_buffer012$Year <- "fc2012"
deforestation_dat_buffer013$Year <- "fc2013"
deforestation_dat_buffer014$Year <- "fc2014"
deforestation_dat_buffer015$Year <- "fc2015"
deforestation_dat_buffer016$Year <- "fc2016"
deforestation_dat_buffer017$Year <- "fc2017"
deforestation_dat_buffer018$Year <- "fc2018"
deforestation_dat_buffer019$Year <- "fc2019"
deforestation_dat_buffer020$Year <- "fc2020"
deforestation_dat_buffer021$Year <- "fc2021"
deforestation_dat_buffer000$Year <- "fc2000"

deforestation_dat_buffer <- rbind(deforestation_dat_buffer000, deforestation_dat_buffer001, deforestation_dat_buffer002, deforestation_dat_buffer003, deforestation_dat_buffer004, deforestation_dat_buffer005, deforestation_dat_buffer006, deforestation_dat_buffer007, deforestation_dat_buffer008, deforestation_dat_buffer009, deforestation_dat_buffer010, deforestation_dat_buffer011, deforestation_dat_buffer012, deforestation_dat_buffer013, deforestation_dat_buffer014, deforestation_dat_buffer015, deforestation_dat_buffer016, deforestation_dat_buffer017, deforestation_dat_buffer018, deforestation_dat_buffer019, deforestation_dat_buffer020, deforestation_dat_buffer021)

deforestation_dat_new_buffer <- left_join(deforestation_dat_buffer, points_buffer, by="OBJECTID")

deforestation_dat_buffer <- deforestation_dat_new_buffer %>% select(NOM, RASTERVALU, Year, OBJECTID)%>%rename(SUM=RASTERVALU) %>% pivot_wider(names_from = "Year", values_from= "SUM")

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

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

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


write.csv(deforestation_dat3_buffer, "~/Documents/GitHub/TourismDeforestation/Data/CommuneForestCover/deforestation_full_points_buffer.csv")

```




