diff --git a/README.md b/README.md index e1ae627..7d734a7 100644 --- a/README.md +++ b/README.md @@ -1 +1,5 @@ # ironwood plots + +Ironwood tree healh data analysis using R. + +![ironwood tree health map](health_map_plot.png) diff --git a/health_map_plot.png b/health_map_plot.png new file mode 100644 index 0000000..8965026 Binary files /dev/null and b/health_map_plot.png differ diff --git a/ironwood_plots.R b/ironwood_plots.R index 4c6210c..c0133c4 100644 --- a/ironwood_plots.R +++ b/ironwood_plots.R @@ -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)})