Skip to content
Snippets Groups Projects
Commit 4a51db3c authored by Francesco Sabatini's avatar Francesco Sabatini
Browse files

06_builDT - added calculation of relative cover

parent 8c2c0eb9
No related branches found
No related tags found
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment