From 4a51db3cbdca48c47016f16024eaa6cb10363f2e Mon Sep 17 00:00:00 2001 From: Francesco Sabatini <francesco.sabatini@idiv.de> Date: Wed, 4 Mar 2020 20:07:50 +0100 Subject: [PATCH] 06_builDT - added calculation of relative cover --- code/06_buildDT.Rmd | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/code/06_buildDT.Rmd b/code/06_buildDT.Rmd index 26f642a..4e3df55 100644 --- a/code/06_buildDT.Rmd +++ b/code/06_buildDT.Rmd @@ -229,7 +229,7 @@ conflict <- DT1 %>% Delete all records of fungi ```{r} -DT1f <- DT1 %>% +DT1 <- DT1 %>% dplyr::select(-Genus) %>% left_join(DT1 %>% distinct(`Matched concept`) %>% @@ -251,12 +251,12 @@ DT1f <- DT1 %>% filter(`Taxon group`!="Mushroom")# %>% #dplyr::select(-Genus) -table(DT1f$`Taxon group`, exclude=NULL) +table(DT1$`Taxon group`, exclude=NULL) ``` Check the most frequent species for which we don't have taxon group info ```{r, echo=F, eval=F} -DT1f %>% +DT1 %>% filter(`Taxon group` == "Unknown") %>% group_by(Genus) %>% summarize(n=n()) %>% @@ -264,15 +264,33 @@ DT1f %>% slice(1:40) ``` -Clean DT and export +Calculate relative cover per layer per species in each plot +```{r} +DT1 <- DT1 %>% + mutate(tmp.cover=ifelse(`Cover code` %in% c("x_BA", "x_IC", "x_SC", "x_IV", "x_RF"), + x_, `Cover %`)) %>% + left_join(x=., + y={.} %>% + group_by(PlotObservationID, Layer) %>% + summarize(tot.cover=sum(tmp.cover)), + by=c("PlotObservationID", "Layer")) %>% + mutate(Relative.cover=tmp.cover/tot.cover) + + +``` + + + + +## Clean DT and export ```{r} DT2 <- DT1 %>% - dplyr::select(PlotObservationID, Name_short, `Turboveg2 concept`, `Taxon group`, Layer:x_ ) %>% - rename(Species_original=`Turboveg2 concept`, - Species_matched=Name_short, - Taxon_group=`Taxon group`, - Cover_perc=`Cover %`, - Cover_code=`Cover code`) + dplyr::select(PlotObservationID, Name_short, `Turboveg2 concept`, `Taxon group`, Layer:x_, Relative.cover ) %>% + rename(species_original=`Turboveg2 concept`, + species=Name_short, + taxon_group=`Taxon group`, + cover_perc=`Cover %`, + cover_code=`Cover code`) ``` The output of the DT table contains `r nrow(DT2)` records, over `r length(unique(DT2$PlotObservationID))` plots. The total number of taxa is `r length(unique(DT2$Species_original))` and `r length(unique(DT2$Species_matched))`, before and after standardization, respectively. Information on the `Taxon group` is available for `r DT2 %>% filter(Taxon_group!="Unknown") %>% distinct(Species_matched) %>% nrow()` standardized species. @@ -284,5 +302,3 @@ save(DT2, file = "../_output/DT_sPlot3.0.RData") ***!!! ADD Explanation of fields!!!*** - -!! It seems there are a few species in Name_sPlot_TRY which are duplicated!!! Check in Backbone -- GitLab