--- 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) ```