update readme, and plot

This commit is contained in:
aaron
2024-06-10 18:29:00 +02:00
parent 06d306afa1
commit fc798080be
3 changed files with 7 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ library(readODS)
library(tidyverse)
library(dplyr)
library(leaflet)
library(RColorBrewer)
##
# parse the input data, declare global values and auxiliary data
@@ -68,6 +69,7 @@ health_counts <- df %>%
# Pivot the data frame to wide format for ggplot
health_counts_wide <- pivot_wider(health_counts, names_from = tree_health_index, values_from = count, values_fill = list(count = 0))
# plot each bar
ggplot(health_counts_wide, aes(x = site_num)) +
geom_bar(aes(fill = `0`), position = "stack", width = 0.5) +
geom_bar(aes(fill = `1`), position = "stack", width = 0.5) +
@@ -78,12 +80,10 @@ ggplot(health_counts_wide, aes(x = site_num)) +
scale_fill_manual(values = c("#1b9e77", "#d95f02", "#7570b3", "#e7298a", "#66a61e")) + # Custom colors for each health index
theme_minimal()
# rename
colnames(health_data) <- paste("Site", seq(1,20), sep=" ")
rownames(health_data) <- condition_names
# create color palette:
library(RColorBrewer)
coul <- brewer.pal(3, "Pastel2")
# Transform this data in %
data_percentage <- apply(data, 2, function(x){x*100/sum(x,na.rm=T)})