The following report delves into the masting behaviors of two maple species: the red maple (Acer rubrum), a non-masting species, and the sugar maple (Acer saccharum), a masting species. Utilizing data collected from Harvard Forest since 2011, This exploration is based on fourteen datasets, each providing unique insights on Maple Reproduction and Sap Flow. The understanding of the datasets is pivotal in addressing our primary research question: does the non-masting red maple exhibit more consistent reproductive patterns compared to the masting sugar maple?”
For a focused analysis, we will delve into two key datasets that include both tree species, as this will enable a direct comparison.
Before diving into the data sets, in our analysis we will employ the tidyverse library for its comprehensive data manipulation and visualization tools, modelr to construct predictive models, and readr and readxl for efficient data importation from various formats. Additionally, the DT package will be used to enhance our data representation through interactive tables, facilitating a dynamic exploration of the findings.
The datasets used in this analysis are sourced from the following study:
Rapp, J., E. Crone, and K. Stinson. 2021. Maple Reproduction and Sap Flow at Harvard Forest since 2011 ver 4. Environmental Data Initiative. https://doi.org/10.6073/pasta/c74eba9dc8ddc41c19dc85e002a3f046 (Accessed 2023-12-15).
library(tidyverse)
library(modelr)
library(readr)
library(readxl)
library(DT)
In our comprehensive analysis, examination of the two datasets encompassed a collective 6,936 entries across 11 distinct variables. These variables provide a profound insight into the dynamics of maple tree species.
The variables included were: ‘date’ (YYYY-MM-DD format for data collection), ‘tree’ (species identifier with HF denoting sugar maples and HFR/AR for red maples, followed by their ID), ‘tap’ (indicating the frequency of sap extraction, A or B, consistent within years). ‘Time’ variable records the precise moment of data collection, and ‘species’ distinguishes between sugar maple (ACSA) and red maple (ACRU). ‘Dbh’ is the diameter at breast height, measured in centimeters. Additionally, ‘tap.bearing’ details the compass direction of the tap, ‘tap.height’ records the height of the tap above ground, ‘datetime’ combines date and time, ‘sugar’ quantifies sugar concentration, and ‘sap.wt’ measures the weight of the sap collected.
Below you will see the two data sets.
Maple_Tap <- read_csv("~/Library/Mobile Documents/com~apple~CloudDocs/Data Analysis with R/Maple Reproduction and Sap Flow at Harvard Forest since 2011/hf285-01-maple-tap.csv")
datatable(Maple_Tap, options = list(scrollX = TRUE))
Maple_Sap <- read_csv("~/Library/Mobile Documents/com~apple~CloudDocs/Data Analysis with R/Maple Reproduction and Sap Flow at Harvard Forest since 2011/hf285-02-maple-sap.csv")
datatable(Maple_Sap, options = list(scrollX = TRUE))
After an in-depth review of our two datasets, we are ready to analyze the masting behaviors of red and sugar maples. We employ ‘summary’ to detect potential data entry errors and ‘head’ for an initial overview of the data.
First up we initiate our analytical process by meticulously cleaning, organizing and tidying up the data sets.This involves using functions like ‘filter’, ‘arrange’ and ‘rename’ to structure the datasets, coupled with strategies to address missing values through ‘mutate’. Critical to our process is the ‘separate’ function, particularly for dissecting composite date columns into year, month, and day segments. Once we achieve a refined state of our datasets, we will merge them for a holistic analysis. Now, it is time to bring out the visualizations, examining correlations and building regression models.
We are on a quest to discover if, in their relationship, sugar and dbh levels in these maples give us further insight about their growth patterns.
Let’s start by the Maple_Tap data set. We will utilize the ‘summary’ function to identify any inaccuracies of missing data (NA values).
Maple_Tap <- read_csv("~/Library/Mobile Documents/com~apple~CloudDocs/Data Analysis with R/Maple Reproduction and Sap Flow at Harvard Forest since 2011/hf285-01-maple-tap.csv", show_col_types = FALSE)
summary(Maple_Tap)
## date tree tap species
## Min. :2012-02-14 Length:382 Length:382 Length:382
## 1st Qu.:2014-02-20 Class :character Class :character Class :character
## Median :2017-02-18 Mode :character Mode :character Mode :character
## Mean :2017-04-19
## 3rd Qu.:2020-02-02
## Max. :2022-02-12
##
## dbh tap.bearing tap.height
## Min. :31.00 Min. : 0.0 Min. : 50.0
## 1st Qu.:54.70 1st Qu.: 76.0 1st Qu.: 99.0
## Median :63.85 Median :180.0 Median :123.0
## Mean :62.87 Mean :173.8 Mean :120.6
## 3rd Qu.:74.88 3rd Qu.:261.0 3rd Qu.:142.0
## Max. :86.20 Max. :359.0 Max. :188.0
## NA's :256 NA's :7 NA's :7
We certainly do identify a big amount of NA values, 256 to precise, in the column ‘dbh’, which we will filter out. Now, in order to clean it and make it nicer, we will rename some of the variables.
`Maple Tap Cleaning Data`<- Maple_Tap%>%
filter(!is.na(dbh))%>%
rename("Date" = date)%>%
rename("Tree" = tree)%>%
rename("Tap" = tap)%>%
rename("Species" = species)%>%
rename("Diameter Breast Height" = dbh)%>%
rename("Tap Bearing" = tap.bearing)%>%
rename("Tap Height" = tap.height)
datatable(`Maple Tap Cleaning Data`, options = list(scrollX = TRUE))
Now, moving to the Maple_Sap data set.
Maple_Sap <- read_csv("~/Library/Mobile Documents/com~apple~CloudDocs/Data Analysis with R/Maple Reproduction and Sap Flow at Harvard Forest since 2011/hf285-02-maple-sap.csv", show_col_types = FALSE)
summary(Maple_Sap)
## date tree tap time
## Min. :2012-02-14 Length:9022 Length:9022 Length:9022
## 1st Qu.:2014-04-06 Class :character Class :character Class1:hms
## Median :2017-02-21 Mode :character Mode :character Class2:difftime
## Mean :2016-11-12 Mode :numeric
## 3rd Qu.:2019-03-14
## Max. :2022-04-03
##
## datetime sugar species
## Min. :2012-02-14 16:25:00.00 Min. : 0.800 Length:9022
## 1st Qu.:2012-03-12 13:37:00.00 1st Qu.: 2.000 Class :character
## Median :2013-03-26 16:06:00.00 Median : 2.400 Mode :character
## Mean :2016-01-17 07:37:08.96 Mean : 2.473
## 3rd Qu.:2020-03-24 16:51:00.00 3rd Qu.: 2.900
## Max. :2022-04-03 15:50:00.00 Max. :22.000
## NA's :7737 NA's :1009
## sap.wt
## Min. : 0.010
## 1st Qu.: 1.460
## Median : 3.180
## Mean : 3.893
## 3rd Qu.: 5.580
## Max. :24.040
## NA's :631
Upon scrutinizing the data set we have find a significant presence of missing values within several columns - ‘datetime’ has 7737 NA entries, ‘sugar’ contains 1009, and ‘sap.wt’ contains 631. Prior to the removal of these NA values, it is essential to investigate any potential issues with data entry. Following this, we will proceed to refine variable names via the ‘rename’ function. Added to this we will also separate the date variable into “year”, “month” and “day”
During the data examination, there was a noticeable jump within some values, making it atypical to have a 22% when the range goes from 0 to 7.3% in this particular dataset, therefore we can confidently say that the 22% was an entry error and needs to be corrected to its real value: 2%. Also, the column “datetime” will be taken out, as it is not necessary when there is another date column as well when the data sets will be merged. Below, we will do the necessary corrections that have been mentioned.
`Maple Sap Cleaning Data`<- Maple_Sap%>%
filter(!is.na(sugar))%>%
filter(sugar<15)%>%
separate(date, into = c("Year", "Month","Day"), convert = TRUE)%>%
rename("Tree" = tree)%>%
rename("Tap" = tap)%>%
rename("Time" = time)%>%
rename("Sugar" = sugar)%>%
rename("Species" = species)%>%
rename("Sap Weight" = sap.wt)
`Maple Sap Cleaning Data` <- subset(`Maple Sap Cleaning Data`, select = - datetime)
datatable(`Maple Sap Cleaning Data`, options = list(scrollX = TRUE))
The result of this merging is displayed below.
`Merged Maple Cleaned Data Set` <- full_join(`Maple Tap Cleaning Data`, `Maple Sap Cleaning Data`, by =c("Tap", "Tree", "Species"))
datatable(`Merged Maple Cleaned Data Set`)
merged_maple_year_boxplot <- `Merged Maple Cleaned Data Set`%>%
mutate(Year = as.character(Year))
ggplot(merged_maple_year_boxplot) +
geom_boxplot(aes(Year,Sugar))
The box plot visualizes the distribution of sugar content in sap over the years, including the median, quartiles, and outliers. What we can observe is that between 2012 and 2015 there has been steady increase in the sugar value, having 2015 as the highest median sugar percentage, indicating it was a peak year for sugar concentration in the sap. Then, there is a fall after 2017, with a light but progressive recovery until 2019. Conversely, 2012 and 2016 show lower medians, suggesting lower sugar content. Additionally, 2017 displays a wide range of values, as indicated by the spread of data points, signifying considerable variability in sugar content during that year. This could reflect environmental factors or tree health impacting sap production.
Below you will see a boxplot of the two species and its sugar contents.
ggplot(`Merged Maple Cleaned Data Set`) +
geom_boxplot(aes(Species, Sugar))
The boxplot illustrates the average sugar content in the sap of red maple (ACRU) and sugar maple (ACSA) species. The masting species, ACSA, shows a consistently higher median sugar content. This graphical representation underscores the metabolic vibrancy of masting species compared to the non-masting ones, providing a visual affirmation of their differential energy requirements.
sugar_model <- lm(Sugar ~ Species, `Merged Maple Cleaned Data Set`)
summary(sugar_model)
##
## Call:
## lm(formula = Sugar ~ Species, data = `Merged Maple Cleaned Data Set`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.7261 -0.4261 -0.0354 0.3739 4.7739
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.83537 0.02136 85.92 <2e-16 ***
## SpeciesACSA 0.69075 0.02180 31.69 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5989 on 19764 degrees of freedom
## (31 observations deleted due to missingness)
## Multiple R-squared: 0.04834, Adjusted R-squared: 0.0483
## F-statistic: 1004 on 1 and 19764 DF, p-value: < 2.2e-16
The statistical analysis indicates that the species classified as ACSA, or sugar maple, shows a statistically significant increase in the sugar content by roughly 0.69%. Despite this increase, the model explains a modest 4.83% of the variability in sugar content, highlighting that other factors also play a role in sugar variation. This conclusion, supported by the model’s low p-values, suggests the species’ influence on sugar content is present but not the sole factor, serving as a basis for further research into the dynamics affecting sap sugar levels.
This comprehensive analysis began with a data cleansing process, followed by the consolidation of two datasets. Further data refinement was carried out to ensure precision. Visual explorations were then conducted, focusing exclusively on the sugar variable across years and species to detect temporal and biological variations.
The analysis concludes that masting maples, exhibiting highly variable seed production patterns, show more dynamic sugar content in their sap compared to non-masting species.
We can infer that the difference lies in the influence of multiple variables or their combination.