move things around
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
40
notebooks/ironwood_project_notebook.Rmd
Normal file
40
notebooks/ironwood_project_notebook.Rmd
Normal file
@@ -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)
|
||||
```
|
||||
1866
notebooks/ironwood_project_notebook.nb.html
Normal file
1866
notebooks/ironwood_project_notebook.nb.html
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user