-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
114 lines (95 loc) · 3.26 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
title: "Final Fate Tracking Project"
author: "Avery Coble"
date: "2023-11-16"
output: html_document
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
#libraries
library(tidyverse)
library(readxl)
library(kableExtra)
library(rcartocolor)
library(patchwork)
#import data
raw.data <- read_xlsx("ArcGIS_FinalData.xlsx", sheet = "FateTracking")%>%
filter(Processed == "Y")
```
# Data Used {.tabset}
## How the raw data was wrangled
```{r}
kable(head(raw.data))%>%
kable_styling(bootstrap_options = "striped")
```
*This table is the first 10 rows of the raw data used in this project. It was full of zeros that represented unanalyzed data, as well as columns that belonged in metadata.*
```{r}
percentages <- raw.data %>%
select("Tag #",
"Actual_Date",
"Total Coral Area Sum (cm2)",
"Live Tissue Sum (cm2)",
"New SCTLD Mortality Sum (cm2)",
"Treatment Used (mL/cc)")%>%
rename("Date" = "Actual_Date",
"Tag" = "Tag #",
"Total_Coral_Area" = "Total Coral Area Sum (cm2)",
"Live_Tissue" = "Live Tissue Sum (cm2)",
"New_SCTLD_Mortality" = "New SCTLD Mortality Sum (cm2)",
"Treatment" = "Treatment Used (mL/cc)")%>%
na.omit()%>%
mutate(Date = mdy(Date),
Percent_Live = Live_Tissue / Total_Coral_Area,
Percent_NewMort = New_SCTLD_Mortality / Total_Coral_Area,
Tag = as.factor(Tag))
kable(head(percentages))%>%
kable_styling(bootstrap_options = "striped")
```
*This table was created to analyze the rate of change in each colonies live tissue and active mortality over time.*
```{r}
counts <- raw.data %>%
select("Tag #",
"Actual_Date",
"# New Lesions (count)",
"# Total Active Lesions (count)",
"Halted Lesions (count)",
"Treatment Used (mL/cc)")%>%
rename("Date" = "Actual_Date",
"Tag" = "Tag #",
"New_Lesions" = "# New Lesions (count)",
"Total_Active_Lesions" = "# Total Active Lesions (count)",
"Halted_Lesions" = "Halted Lesions (count)",
"Treatment_Used" = "Treatment Used (mL/cc)")%>%
na.omit()%>%
mutate(Date = mdy(Date),
Tag = as.factor(Tag))
kable(head(counts))%>%
kable_styling(bootstrap_options = "striped")
```
*This table was created to show the changes in number of active and halted diseased lesion on each colony over time.*
# Visualization {.tabset}
## Graph showing live tissue and new mortality
```{r}
Colony_Tag_Number <- hcl.colors(10, palette = "Roma", alpha = NULL)
plots <- function(data, x, y, z){
p <- ggplot(data, aes({{x}},{{y}}, color = {{z}})) +
geom_point() +
geom_line() +
scale_color_carto_d("Colony_Tag_Number")
return(p)
}
LiveT <- plots(percentages, Date, Percent_Live, Tag)
NewM <- plots(percentages, Date, Percent_NewMort, Tag)
NewL <- plots(counts, Date, New_Lesions, Tag)
ActiveL <- plots(counts, Date, Total_Active_Lesions, Tag)
HaltedL <- plots(counts, Date, Halted_Lesions, Tag)
Treatment <- plots(percentages, Date, Treatment, Tag)
tissue <- LiveT + NewM + Treatment + plot_layout(guides = "collect")
tissue
```
# Visualization {.tabset}
## Graph showing live tissue and new mortality
```{r, results='asis'}
lesions <- ActiveL + HaltedL + Treatment + plot_layout(guides = "collect")
print(lesions)