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

Created script 02 for compiling dataset to solve all issues discovered in 00 and 01

parent b291f906
Branches
No related tags found
No related merge requests found
---
title: "02_sPlot_compile.Rmd"
author: "Francesco Maria Sabatini"
date: "7/8/2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Previously known problems still to be fixed:
1) Import field 'Plants Recorded' into header (SH) - create dictionary of possible factors (FMS)
2) Import field 'Herbs identified' into header (SH)
3) Database with empty 'Cover code' value in DT - British_columbia_meadows and USA_VegBank (FMS)
4) Formations - Assign zeros to columns (Forest, Grassland, Shrubland, Wetland, Sparse), when at least one 1
5) Link to EUNIS cross-link table, and assign Faber-Langedon Formation (FMS)
6) Assign plot elevation using external sources (FMS)
7) Add GIVD codes
Arbitrarily set location uncertainty to -100, for missing values
Additional data from external sources
1) SoilGrids
2) Chelsa
!!! ADD ALSO A NOTE TO THE _x field to mention this is pa data !!!
3) Fix problem for British_Columbia_meadows, by arbitrarily assigning a 0.1% cover to all lichens/mosses
```{r}
DT0 <- DT0 %>%
mutate(`Cover %` = replace(`Cover %`,
list= `Cover %` ==0 &
is.na(`Cover code`) &
Taxonomy=="British_Columbia_meadows" &
Layer=="9",
values= 0.1))
```
Fix problems for USA_VegBank, by arbitrarily assigning a 0.1% cover to all species without cover value
```{r}
DT0 <- DT0 %>%
mutate(`Cover %` = replace(`Cover %`,
list= `Cover %` ==0 &
is.na(`Cover code`) &
Taxonomy=="USA_VegBank",
values= 0.1))
```
4) Formations - Assign zeros to columns (Forest, Grassland, Shrubland, Wetland, Sparse), when at least one 1 is present (FMS)
```{r}
header <- header %>%
mutate(any1=rowSums(select(., Forest:Shrubland), na.rm=T)) %>%
mutate_at(.vars = vars(Forest:Shrubland),
.funs = ~ifelse(any1>0, ifelse(!is.na(.), ., 0), 0)) %>%
select(Forest:Shrubland, any1) %>%
filter(any1>0)
```
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment