update readme, and plot
This commit is contained in:
@@ -1 +1,5 @@
|
||||
# ironwood plots
|
||||
|
||||
Ironwood tree healh data analysis using R.
|
||||
|
||||

|
||||
|
||||
BIN
health_map_plot.png
Normal file
BIN
health_map_plot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 MiB |
@@ -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)})
|
||||
|
||||
Reference in New Issue
Block a user