#Ask

#Business Objective

#Identifying if Ogoomi Farms met its yearly target for net zero emissions through #tree carbon sequestrations.

#Business Task

#To find the amount of CO2 sequestered by black Cherry trees on T2 plantation

#Stakeholders #Emmanuel Owusu: The Climate Change and carbon management head of Ogoomi Farms.He is responsible for proofing to management #that the back cherry tree planting project on T2 has a net agroforestry benefit for the #company and society in general

#Ogoomi Farms executive. They will check to see if the project is worth the company’s resources and decide if to continue to invest in the project

#Ogoomi Farms sustainability analytics team. They are responsible for collecting, analyzing and reporting data that helps guide the company.

#Prepare

##location of data

#The data used can be found on CRANS R studio (trees).

##Data Organization #The data is stored on RStudio directory and has 3 columns and 31 rows.

##Credibility of Data #Rstudio is a platform that makes sures all data and codes stored on its server are credible.

##Usefulness of Data

#The allometric data collected is useful in deriving other data on weight, dry weight, #and weight of CO2

#Problems with dataset #Data was explored for inaccuracies, inconsistency, outdated, duplicates and incomplete data #data was clean.

#Process #I chose RStudio to explore,analyse and visualise data

#Install needed packages

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0      ✔ purrr   0.3.5 
## ✔ tibble  3.1.8      ✔ dplyr   1.0.10
## ✔ tidyr   1.2.1      ✔ stringr 1.4.1 
## ✔ readr   2.1.3      ✔ forcats 0.5.2 
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()

#Explore data

data(trees)
View(trees)
head(trees)
##   Girth Height Volume
## 1   8.3     70   10.3
## 2   8.6     65   10.3
## 3   8.8     63   10.2
## 4  10.5     72   16.4
## 5  10.7     81   18.8
## 6  10.8     83   19.7
summary(trees)
##      Girth           Height       Volume     
##  Min.   : 8.30   Min.   :63   Min.   :10.20  
##  1st Qu.:11.05   1st Qu.:72   1st Qu.:19.40  
##  Median :12.90   Median :76   Median :24.20  
##  Mean   :13.25   Mean   :76   Mean   :30.17  
##  3rd Qu.:15.25   3rd Qu.:80   3rd Qu.:37.30  
##  Max.   :20.60   Max.   :87   Max.   :77.00
names(trees)
## [1] "Girth"  "Height" "Volume"
unique(trees$Volume)
##  [1] 10.3 10.2 16.4 18.8 19.7 15.6 18.2 22.6 19.9 24.2 21.0 21.4 21.3 19.1 22.2
## [16] 33.8 27.4 25.7 24.9 34.5 31.7 36.3 38.3 42.6 55.4 55.7 58.3 51.5 51.0 77.0
str(trees)
## 'data.frame':    31 obs. of  3 variables:
##  $ Girth : num  8.3 8.6 8.8 10.5 10.7 10.8 11 11 11.1 11.2 ...
##  $ Height: num  70 65 63 72 81 83 66 75 80 75 ...
##  $ Volume: num  10.3 10.3 10.2 16.4 18.8 19.7 15.6 18.2 22.6 19.9 ...

#Selecting dataframes

trees_1<-trees %>% 
  select(Girth,Height)
View(trees_1)

#Change name from Girth to Diameter for consistency

tree_2<-trees_1 %>% 
  rename(diameter=Girth)
View(tree_2)
glimpse(trees)
## Rows: 31
## Columns: 3
## $ Girth  <dbl> 8.3, 8.6, 8.8, 10.5, 10.7, 10.8, 11.0, 11.0, 11.1, 11.2, 11.3, …
## $ Height <dbl> 70, 65, 63, 72, 81, 83, 66, 75, 80, 75, 79, 76, 76, 69, 75, 74,…
## $ Volume <dbl> 10.3, 10.3, 10.2, 16.4, 18.8, 19.7, 15.6, 18.2, 22.6, 19.9, 24.…

#convert height in cm to inches and square the value of diameter into a new column

tree_3<-tree_2 %>% 
  mutate(Height_ft=Height*0.0328,
         diameter_square=diameter^2)
View(tree_3)

#create additional columns based on diameter and height

tree_4<-tree_3 %>% 
  mutate(Weight=0.15*diameter_square*Height_ft,
         Dry_weight=0.725*Weight,
         Carbon_weight=0.5*Dry_weight,
         CO2_weight=Carbon_weight*3.6663,
         CO2_per_year=CO2_weight/5)
View(tree_4)

#Analysis

#Calculating total amount of C02 sequestered by Black cherry trees in their #second year

TCO2<-tree_4 %>% 
  summarise(Total_CO2=sum(CO2_per_year))
View(TCO2)
Tree_6<-tree_4 %>% 
  mutate(tree_number=1:31)
View(Tree_6)

#create a data frame for amount of carbon sequestered per tree

tree_CO2<-Tree_6 %>% 
  select(tree_number,CO2_per_year)
View(tree_CO2)

#Summary The Blackberry trees sequestered 581.4534 metric tonnes of CO2 in its second year.

#Share

##Data visualization

tree_CO2 %>% 
  ggplot(aes(tree_number,CO2_per_year))+geom_col(position = "dodge")+scale_y_continuous()+
  labs(title = "Amount of CO2 sequestered by trees", caption = "Figure 1", x="Tree ID",y="Amount of CO2 sequestered",)+
  theme()

#Act #The data provided indicates Ogoomi Farms have meet their carbon sequestration projections #which will intend help the farms meet its net zero objectives for the first quarter on 2022