https://github.com/tom-n-walker/uphill-plants-soil-carbon
Tip revision: 951e73295060ad88bddf5d48a3aa4b9d90475312 authored by Tom Walker on 07 September 2021, 14:32:36 UTC
Merge branch 'main' of github.com:tom-n-walker/uphill-plants-soil-carbon into main
Merge branch 'main' of github.com:tom-n-walker/uphill-plants-soil-carbon into main
Tip revision: 951e732
load_fluxes.R
################################################################################
#### Project: Lowland plant migrations alpine soil C loss
#### Title: Function | Load flux data
#### Author: Tom Walker (thomas.walker@usys.ethz.ch)
#### Date: 26 May 2021
#### ---------------------------------------------------------------------------
load_fluxes <- function(){
# load fluxes
calFlux <- fread("./data/field_calanda_gases.csv") %>%
mutate(Treatment = substr(Treatment, nchar(Treatment), nchar(Treatment))) %>%
mutate(site = "calanda") %>%
# add leading zero to block
mutate(Block = ifelse(
nchar(Block) == 3,
Block,
paste0(substr(Block, 1, 1), "0", substr(Block, 2, 2))
)) %>%
select(site, Date, Block, Treatment, Temp.C:PAR, GPP, NEE, ER) %>%
dplyr::rename_with(.cols = Date:Treatment, tolower)
lavFlux <- fread("./data/field_lavey_gases.csv") %>%
mutate(Treatment = substr(Treatment, nchar(Treatment), nchar(Treatment))) %>%
mutate(site = "lavey") %>%
# add leading zero to block
mutate(Block = ifelse(
nchar(Block) == 3,
Block,
paste0(substr(Block, 1, 1), "0", substr(Block, 2, 2))
)) %>%
select(site, Date, Block, Treatment, Temp.C:PAR, GPP, NEE, ER) %>%
dplyr::rename_with(.cols = Date:Treatment, tolower)
# collate & return
fluxes <- bind_rows(calFlux, lavFlux) %>% as.data.frame
return(fluxes)
}