-
Notifications
You must be signed in to change notification settings - Fork 2
/
species_concistency_check_DYFS.R
66 lines (48 loc) · 1.67 KB
/
species_concistency_check_DYFS.R
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
library(icesDatras)
library(worrms)
d <- getDATRAS(record="HL", "DYFS",years=2023,quarters=c(3,4))
#save d
#save(d,file="d:/WGBEAM2024/DYFS_species.RData")
###total number of AphiaIDs
length(unique(d$Valid_Aphia))
####number of species per Country
NL <- subset(d, d$Country=="NL")
length(unique(NL$Valid_Aphia))
BE <- subset(d, d$Country=="BE")
length(unique(BE$Valid_Aphia))
DE <- subset(d, d$Country=="DE")
length(unique(DE$Valid_Aphia))
####conect Aphia_IDs to WORMS (using worrms)
specs <- unique(d$Valid_Aphia)
t <- c()
for(i in 1:length(specs)){
t1 <- wm_record(specs[i])
t <- rbind(t, t1)}
unac <- subset(t, t$status=="unaccepted")
unique(unac$AphiaID)
unique(unac$scientificname)
unique(unac$valid_AphiaID)
unique(unac$valid_name)
dubio <- subset(t, t$status=="nomen dubium")
######create look up table to check occurence of species per country
d$count <- d$SubFactor*d$HLNoAtLngt
d$count[d$HLNoAtLngt==-9] <- d$TotalNo[d$HLNoAtLngt==-9]
dat1 <- aggregate(count~Valid_Aphia+Country,data=d,FUN="sum")
dat1$species <- wm_id2name_(id=dat1$Valid_Aphia)
dat1BE <- subset(dat1, dat1$Country=="BE")
colnames(dat1BE)[3] <- "BE"
dat1BE$Country <- NULL
dat1NL <- subset(dat1, dat1$Country=="NL")
colnames(dat1NL)[3] <- "NL"
dat1NL$Country <- NULL
dat1DE <- subset(dat1, dat1$Country=="DE")
colnames(dat1DE)[3] <- "DE"
dat1DE$Country <- NULL
ltable <- merge(dat1BE,dat1NL, all=T)
ltable <- merge(ltable, dat1DE, all=T)
ltable[ltable<=0] <- -9
ltable$species <- as.character(ltable$species)
ltable <- ltable[order(ltable$species),]
#####save ltable
#setwd("d:/WGBEAM2024/")
#write.table(ltable, "Test_2023.csv",sep=",", row.names=F)