-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreate Q_SPECIE.Rmd
73 lines (58 loc) · 2.23 KB
/
Create Q_SPECIE.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
title: "Create Q_SPECIE"
author: "Sander Devisscher"
date: "15 februari 2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r libraries}
library(readr)
library(foreign)
library(dplyr)
```
```{r read existing Q_Specie}
Q_Specie <- read_csv("G://Mijn Drive/INBOPRJ-10217 - Monitoring exoten ikv EU- verordening IAS Coördinatie, voorbereiding, implementatie en opvolging/EASIN/Data/EASIN files/Q_SPECIE.csv")
```
```{r T0_Species}
T0 <- read_csv2("./Output/GRID10kData_Source_20_02_18_Export_20_02_18.csv")
T0$X <- NULL
SPEC_T0 <- unique(T0$species)
T0_Species <- data.frame(SPEC_T0)
T0_Species$SPEC_T0 <- as.character(T0_Species$SPEC_T0)
T0_Species$SPEC <- gsub(" ", "_", T0_Species$SPEC_T0)
T0_Species$SPEC <- gsub(".", "_", T0_Species$SPEC, fixed = T )
T0_Species$SPEC <- gsub(",", "_", T0_Species$SPEC, fixed = T )
T0_Species$SPEC <- gsub("&", "_", T0_Species$SPEC, fixed = T )
T0_Species$SPEC <- gsub("(", "_", T0_Species$SPEC, fixed = T )
T0_Species$SPEC <- gsub(")", "_", T0_Species$SPEC, fixed = T )
```
```{r EASIN_Species}
Batchnummer <- 2
EASIN_NEW <- read.dbf("G://Mijn Drive/INBOPRJ-10217 - Monitoring exoten ikv EU- verordening IAS Coördinatie, voorbereiding, implementatie en opvolging/EASIN/Data/EASIN files/Tweede batch/EASIN check/EASIN baseline check.dbf")
SPEC_EASIN <- unique(EASIN_NEW$Species)
EASIN_Species <- data.frame(SPEC_EASIN)
EASIN_Species$Batch <- as.integer(Batchnummer)
EASIN_Species$SPEC_EASIN <- as.character(EASIN_Species$SPEC_EASIN)
#Check for species not yet present in Q_Specie
temp <- anti_join(EASIN_Species, Q_Specie, by = "SPEC_EASIN")
if(nrow(temp)>0){
temp_species <- unique(temp$SPEC_EASIN)
for(s in temp_species){
temp2 <- subset(Q_Specie, pmatch(x = SPEC_T0, y = s, duplicates.ok = F ))
if(nrow(temp2)>0){
Q_Specie$SPEC_EASIN <- s
Q_Specie$Batch <- as.integer(Batchnummer)
}else{
print(s, " is not present in T0 Sourcedata")
}
}
}
Q_Specie$Batch <- ifelse(is.na(Q_Specie$SPEC_EASIN), NA, Q_Specie$Batch)
```
```{r Merge}
```
```{r Export}
write_csv(Q_Specie, "G://Mijn Drive/INBOPRJ-10217 - Monitoring exoten ikv EU- verordening IAS Coördinatie, voorbereiding, implementatie en opvolging/EASIN/Data/EASIN files/Q_SPECIE.csv")
```