diff --git a/ironwood_data_cleaned.ods b/data/ironwood_data_cleaned.ods similarity index 100% rename from ironwood_data_cleaned.ods rename to data/ironwood_data_cleaned.ods diff --git a/ironwood_data_original.ods b/data/ironwood_data_original.ods similarity index 100% rename from ironwood_data_original.ods rename to data/ironwood_data_original.ods diff --git a/ironwood_plots.R b/ironwood_plots.R index 1fd8985..1665161 100644 --- a/ironwood_plots.R +++ b/ironwood_plots.R @@ -12,12 +12,14 @@ library(leaflet) ## # read a data frame from the ods document -df <- read_ods("ironwood_data_cleaned.ods", sheet = 1) +df <- read_ods("data/ironwood_data_cleaned.ods", sheet = 1) # site base location site_lat <- "-33.943917" site_lon <- "23.507389" # vector of condition names corresponding to the health index numbers -condition_names <- c("healthy", "light damage", "medium damage", "severe damage", "at point of death") +condition_names <- c("healthy", "light damage", + "medium damage", "severe damage", + "at point of death") # colors for each condition condition_colors <- c("green", "yellow", "orange", "red", "black") diff --git a/notebooks/ironwood_project_notebook.Rmd b/notebooks/ironwood_project_notebook.Rmd new file mode 100644 index 0000000..04404eb --- /dev/null +++ b/notebooks/ironwood_project_notebook.Rmd @@ -0,0 +1,40 @@ +--- +title: "ironwood project" +output: html_notebook +--- + +First lets assess the health of the population. + +```{r} +# read a data frame from the ods document +df <- read_ods("../data/ironwood_data_cleaned.ods", sheet = 1) +# site base location +site_lat <- "-33.943917" +site_lon <- "23.507389" +# vector of condition names corresponding to the health index numbers +condition_names <- c("healthy", "light damage", + "medium damage", "severe damage", + "at point of death") +# colors for each condition +condition_colors <- c("green", "yellow", "orange", "red", "black") +# Calculate the percentage of trees in each health condition +percentage <- proportions(table(df$tree_health_index)) * 100 +# Now, let's create the bar plot +barplot(percentage, + names.arg = condition_names, + main = "Overview of Tree Health Index", + xlab = "Health Index", + ylab = "Percentage of Trees", + ylim = c(0, max(percentage) + 10), + col = condition_colors, + border = "black") +# Adding a legend +legend("topright", + legend = condition_names, + fill = condition_colors) +# Add labels with the percentage of trees in each bar +text(x = barplot(percentage, plot = FALSE), + y = percentage, + labels = paste0(round(percentage, 1), "%"), + pos = 3) +``` diff --git a/notebooks/ironwood_project_notebook.nb.html b/notebooks/ironwood_project_notebook.nb.html new file mode 100644 index 0000000..23ed321 --- /dev/null +++ b/notebooks/ironwood_project_notebook.nb.html @@ -0,0 +1,1866 @@ + + + + +
+ + + + + + + + +First lets assess the health of the population.
+ + + +# read a data frame from the ods document
+df <- read_ods("../data/ironwood_data_cleaned.ods", sheet = 1)
+# site base location
+site_lat <- "-33.943917"
+site_lon <- "23.507389"
+# vector of condition names corresponding to the health index numbers
+condition_names <- c("healthy", "light damage",
+ "medium damage", "severe damage",
+ "at point of death")
+# colors for each condition
+condition_colors <- c("green", "yellow", "orange", "red", "black")
+# Calculate the percentage of trees in each health condition
+percentage <- proportions(table(df$tree_health_index)) * 100
+# Now, let's create the bar plot
+barplot(percentage,
+ names.arg = condition_names,
+ main = "Overview of Tree Health Index",
+ xlab = "Health Index",
+ ylab = "Percentage of Trees",
+ ylim = c(0, max(percentage) + 10),
+ col = condition_colors,
+ border = "black")
+# Adding a legend
+legend("topright",
+ legend = condition_names,
+ fill = condition_colors)
+# Add labels with the percentage of trees in each bar
+text(x = barplot(percentage, plot = FALSE),
+ y = percentage,
+ labels = paste0(round(percentage, 1), "%"),
+ pos = 3)
+
+
+
+