Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
813 changes: 813 additions & 0 deletions trees/height-diameter/ARME.R

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions trees/height-diameter/AUC.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#install packages
library(dplyr)
library(ggplot2)
library(furrr)
Expand Down
813 changes: 813 additions & 0 deletions trees/height-diameter/PISI.R

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions trees/height-diameter/Questions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Line 113 to 159, none of the model converged

Getting NA values in AIC and parameters
814 changes: 814 additions & 0 deletions trees/height-diameter/RHPU.R

Large diffs are not rendered by default.

68 changes: 68 additions & 0 deletions trees/height-diameter/Species Composition.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
library(dplyr)
library(ggplot2)
library(readr)
library(cowplot)

# Read your dataset
df <- read_csv("Elliott_timber_cruise_2015-16.csv") # Replace with your file path

# Filter NA values
filtered_df <- df %>%
filter(!is.na(totalHt), !is.na(DBH))

# Define species full names
species_lookup <- c(
"PSME" = "Douglas-fir",
"ALRU2" = "Red alder",
"TSHE" = "Western hemlock",
"ACMA3" = "Bigleaf maple",
"UMCA" = "California bay",
"THPL" = "Western redcedar",
"PISI" = "Sitka spruce",
"RHPU" = "Cascara buckthorn",
"ARME" = "Pacific madrone",
"Other" = "Other"
)

# Summarize counts with full name labels
species_counts <- filtered_df %>%
mutate(species_category = ifelse(species %in% names(species_lookup), species, "Other")) %>%
count(species_category, name = "count") %>%
mutate(
species_full = species_lookup[species_category],
species_full = factor(species_full, levels = species_lookup[unique(species_category)])
)

# MAIN BARPLOT
main_bar <- ggplot(species_counts, aes(x = species_full, y = count)) +
geom_col(fill = "darkgrey") +
geom_text(aes(label = count), vjust = -0.5, size = 4)+
labs(title = "Overall Species Composition", x = "Species", y = "Number of Trees") +
theme_minimal(base_size = 14) +
theme(axis.text.x = element_text(angle = 45, hjust = 1,size=16))

# ZOOMED-IN BARPLOT FOR RARE SPECIES
zoom_species <- species_counts %>%
filter(species_category %in% c("ARME", "RHPU", "PISI"))

zoom_bar <- ggplot(zoom_species, aes(x = species_full, y = count)) +
geom_col(fill = "darkorange") +
geom_text(aes(label = count), vjust = -0.5, size = 3.5)+
labs(title = "Species of Interest", x = NULL, y = NULL) +
theme_minimal(base_size = 9) +
theme(
axis.text.x = element_text(size=12,angle = 30, hjust = 1),
plot.title = element_text(size = 12, face = "bold")
)

# COMBINE PLOTS WITH SMALLER INSET
final_plot <- ggdraw() +
draw_plot(main_bar, 0, 0, 1, 1) +
draw_plot(zoom_bar, x = 0.68, y = 0.68, width = 0.28, height = 0.28)

# Show it
print(final_plot)

# Save final plot to PNG
ggsave("species_composition_inset.png", plot = final_plot, width = 10, height = 7, dpi = 300)

299 changes: 160 additions & 139 deletions trees/height-diameter/THPL.R

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions trees/height-diameter/not_significant.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


#get the models that are not significant from base model

temp<-heightDiameterResults %>% group_by(responseVariable,species) %>% filter(significant=="FALSE") %>% reframe(unique(name))
write.csv(temp,"not_significant.csv")
353 changes: 312 additions & 41 deletions trees/height-diameter/results.R

Large diffs are not rendered by default.

1,138 changes: 610 additions & 528 deletions trees/height-diameter/setup.R

Large diffs are not rendered by default.