From 6a019131f43f340f94f73ba54d6c6dbff7c62237 Mon Sep 17 00:00:00 2001 From: audhalbritter Date: Tue, 16 May 2023 14:55:52 +0200 Subject: [PATCH 1/3] move cleaning code to folders in R folder --- R/{ => cn_cycling}/Clean_PRS_probes.R | 0 {Code_cleaning => R/cn_cycling}/clean_CNP_core_depths.R | 0 {Code_cleaning => R/cn_cycling}/clean_LOI.R | 0 R/{ => environment}/Clean_Climate_TOMST.R | 0 {Code_cleaning => R/environment}/clean_slope_and_aspect.R | 0 {Code_cleaning => R/environment}/clean_soil_depth_measurements.R | 0 .../environment}/clean_soil_moisture_point_measurements.R | 0 .../vegetation}/clean_greenseeker_measurements_2022.R | 0 {Code_cleaning => R/vegetation}/clean_root_ingrowtn_core_depths.R | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename R/{ => cn_cycling}/Clean_PRS_probes.R (100%) rename {Code_cleaning => R/cn_cycling}/clean_CNP_core_depths.R (100%) rename {Code_cleaning => R/cn_cycling}/clean_LOI.R (100%) rename R/{ => environment}/Clean_Climate_TOMST.R (100%) rename {Code_cleaning => R/environment}/clean_slope_and_aspect.R (100%) rename {Code_cleaning => R/environment}/clean_soil_depth_measurements.R (100%) rename {Code_cleaning => R/environment}/clean_soil_moisture_point_measurements.R (100%) rename {Code_cleaning => R/vegetation}/clean_greenseeker_measurements_2022.R (100%) rename {Code_cleaning => R/vegetation}/clean_root_ingrowtn_core_depths.R (100%) diff --git a/R/Clean_PRS_probes.R b/R/cn_cycling/Clean_PRS_probes.R similarity index 100% rename from R/Clean_PRS_probes.R rename to R/cn_cycling/Clean_PRS_probes.R diff --git a/Code_cleaning/clean_CNP_core_depths.R b/R/cn_cycling/clean_CNP_core_depths.R similarity index 100% rename from Code_cleaning/clean_CNP_core_depths.R rename to R/cn_cycling/clean_CNP_core_depths.R diff --git a/Code_cleaning/clean_LOI.R b/R/cn_cycling/clean_LOI.R similarity index 100% rename from Code_cleaning/clean_LOI.R rename to R/cn_cycling/clean_LOI.R diff --git a/R/Clean_Climate_TOMST.R b/R/environment/Clean_Climate_TOMST.R similarity index 100% rename from R/Clean_Climate_TOMST.R rename to R/environment/Clean_Climate_TOMST.R diff --git a/Code_cleaning/clean_slope_and_aspect.R b/R/environment/clean_slope_and_aspect.R similarity index 100% rename from Code_cleaning/clean_slope_and_aspect.R rename to R/environment/clean_slope_and_aspect.R diff --git a/Code_cleaning/clean_soil_depth_measurements.R b/R/environment/clean_soil_depth_measurements.R similarity index 100% rename from Code_cleaning/clean_soil_depth_measurements.R rename to R/environment/clean_soil_depth_measurements.R diff --git a/Code_cleaning/clean_soil_moisture_point_measurements.R b/R/environment/clean_soil_moisture_point_measurements.R similarity index 100% rename from Code_cleaning/clean_soil_moisture_point_measurements.R rename to R/environment/clean_soil_moisture_point_measurements.R diff --git a/Code_cleaning/clean_greenseeker_measurements_2022.R b/R/vegetation/clean_greenseeker_measurements_2022.R similarity index 100% rename from Code_cleaning/clean_greenseeker_measurements_2022.R rename to R/vegetation/clean_greenseeker_measurements_2022.R diff --git a/Code_cleaning/clean_root_ingrowtn_core_depths.R b/R/vegetation/clean_root_ingrowtn_core_depths.R similarity index 100% rename from Code_cleaning/clean_root_ingrowtn_core_depths.R rename to R/vegetation/clean_root_ingrowtn_core_depths.R From ba89b6aa2efd485c716f73a872e6cd46fd90f846 Mon Sep 17 00:00:00 2001 From: audhalbritter Date: Wed, 3 Jan 2024 13:50:32 +0100 Subject: [PATCH 2/3] add 2022 biomass cleaning code --- R/load_packages.R | 1 + R/read_biomass.R | 74 +++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 70 insertions(+), 5 deletions(-) diff --git a/R/load_packages.R b/R/load_packages.R index e7bf673..117bac0 100644 --- a/R/load_packages.R +++ b/R/load_packages.R @@ -9,4 +9,5 @@ library(writexl) #devtools::install_github("Between-the-Fjords/dataDownloader") library(dataDownloader) library(validate) +library(janitor) diff --git a/R/read_biomass.R b/R/read_biomass.R index f7a00c8..89e4f5d 100644 --- a/R/read_biomass.R +++ b/R/read_biomass.R @@ -7,14 +7,20 @@ source("R/load_packages.R") #Download data from OSF # run the code from L10-L13 if you need to download the data from OSF -# get_file(node = "4c5v2", -# file = "FunCaB_raw_biomass_2015_2021.csv", -# path = "data/biomass", -# remote_path = "Vegetation data/Functional Group Biomass Removals") +get_file(node = "4c5v2", + file = "FunCaB_raw_biomass_2015_2021.csv", + path = "raw_data/biomass", + remote_path = "Vegetation data/Functional Group Biomass Removals") +# download 2022 data +get_file(node = "tx9r2", + file = "FUNDER Forbs_Graminoids_Bryophytes.xlsx", + path = "raw_data/biomass", + remote_path = "1_Vegetation/Raw_data") -path <- "data/biomass/FunCaB_raw_biomass.xlsx" +### 2015 - 2021 +path <- "raw_data/biomass/FunCaB_raw_biomass.xlsx" biomass_raw <- path %>% excel_sheets() %>% @@ -72,3 +78,61 @@ biomass %>% facet_grid(year ~ site) + theme_bw() + + + +### 2022 +raw_biomass22 <- read_excel("raw_data/biomass/FUNDER Forbs_Graminoids_Bryophytes.xlsx", + sheet = "Dried weight") |> + clean_names() + + +biomass <- raw_biomass22 |> + filter(!is.na(site)) |> + mutate(site = recode(site, + 'GUD' = "Gudmedalen", + 'LAV' = "Lavisdalen", + 'RAM' = "Rambera", + 'ULV' = "Ulvehaugen", + 'SKJ' = "Skjelingahaugen", + 'ALR' = "Alrust", + 'ARH' = "Arhelleren", + 'FAU' = "Fauske", + 'HOG' = "Hogsete", + 'OVS' = "Ovstedalen", + 'VIK' = "Vikesland", + 'VES' = "Veskre")) |> + pivot_longer(cols = c(bryophytes_g, forbs_g, graminoids_g, lichen_g), names_to = "removed_fg", values_to = "biomass") |> + # remove entries without biomass + filter(biomass > 0) |> + mutate(removed_fg = case_match(removed_fg, + "bryophytes_g" ~ "B", + "forbs_g" ~ "F", + "graminoids_g" ~ "G", + "lichen_g" ~ "L")) |> + # indicate fg not in treatment (= leftover) + mutate(no_treatment = case_when(removed_fg == "L" ~ "leftover", + treatment == "FB" & removed_fg == "G" ~ "leftover", + treatment == "GF" & removed_fg == "B" ~ "leftover", + treatment == "GB" & removed_fg == "F" ~ "leftover", + treatment == "G" & removed_fg %in% c("F", "B") ~ "leftover", + treatment == "B" & removed_fg %in% c("F", "G") ~ "leftover", + treatment == "F" & removed_fg %in% c("G", "B") ~ "leftover", + TRUE ~ NA_character_)) |> + select(siteID = site, blockID = block, treatment, removed_fg, biomass, no_treatment, comments) + +write_csv(biomass, "clean_data/FUNDER_clean_biomass_2022.csv") + + +biomass %>% + mutate(treatment = factor(treatment, levels = c("C", "B", "F", "G", "FB", "GB", "GF", "FGB")), + siteID = factor(siteID, levels = c("Skjelingahaugen", "Gudmedalen", "Lavisdalen", "Ulvehaugen", + "Veskre", "Rambera", "Hogsete", "Alrust", + "Ovstedalen", "Arhelleren", "Vikesland", "Fauske"))) %>% + filter(!no_treatment %in% c("leftover"), + treatment != "C") |> + ggplot(aes(x = treatment, y = biomass, fill = removed_fg)) + + geom_col() + + scale_fill_manual(values = c("darkgreen", "violet", "lightblue3")) + + facet_wrap(~ siteID) + + theme_bw() From e13d008069c3469cd2728d7d3627128924d49ee6 Mon Sep 17 00:00:00 2001 From: audhalbritter Date: Wed, 3 Jan 2024 14:09:56 +0100 Subject: [PATCH 3/3] move code to folder --- R/{ => vegetation}/read_biomass.R | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename R/{ => vegetation}/read_biomass.R (100%) diff --git a/R/read_biomass.R b/R/vegetation/read_biomass.R similarity index 100% rename from R/read_biomass.R rename to R/vegetation/read_biomass.R