-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA027_Fix_mydata_R2.R
121 lines (100 loc) · 3.79 KB
/
A027_Fix_mydata_R2.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
library(tidyverse)
load("../sPlot/_input/Mydata_global_NatCommR1.RData")
load("/data/sPlot/releases/sPlot2.1/DT2_20161025.RData")
DT2 -> DT2.1
load("/data/sPlot/releases/sPlot3.0/DT_sPlot3.0.RData")
DT2 -> DT3
rm(DT2)
### Check VegBank Data
#between 40-50° N and 103-125 ° W
vb <- read_csv("../sPlot/_input/USA_VegBank_check/VegBank_to_check.csv")
inw <- vb %>%
filter(str_detect(authorplotcode_vb, "^INW")) %>%
pull(RELEVE_NR)
inw3 <- mydata %>%
filter(POINT_Y>40 & POINT_Y<50 & POINT_X< -103 & POINT_X> -125) %>%
filter(RELEVE_NR %in% inw) %>%
filter(rich.complete<5) %>%
pull(RELEVE_NR)
DT2.1 %>% filter(PlotObservationID == sample(inw3, 1))
rejects <- openxlsx::read.xlsx("../sPlot/_input/USA_VegBank_check/Rejects2F.xlsx", sheet = 1) %>%
filter(!is.na(authorplotcode_vb))
rejects.vegbank <- vb %>%
filter(authorplotcode_vb %in% rejects$authorplotcode_vb) %>%
pull(RELEVE_NR)
## Check species poor plots
aa <- mydata %>%
#filter(RELEVE_NR %in% res$RELEVE_NR) %>%
filter(rich.complete<3) %>%
filter(plants_recorded=="complete") %>%
pull(RELEVE_NR)
# check species in species poor plots
DT2.1 %>%
as_tibble() %>%
dplyr::filter(PlotObservationID %in% aa) %>%
count(species) %>%
arrange(desc(n))
### Exclude wetland plots, based on hydrophytes
wetland.species <- c('Lemna minor',
'Lemna trisulca',
'Spirodela polyrrhiza',
'Glyceria fluitans',
"Glyceria notata",
"Myriophyllum implicatum",
"Myriophyllum verticillatum",
"Myriophyllum sibiricum",
"Myriophyllum spicatum",
"Myriophyllum alterniflorum",
"Stuckenia pectinata",
"Lemna",
"Lemna gibba",
"Alisma plantago-aquatica",
"Callitriche hermaphroditica",
"Ceratophyllum demersum",
"Potamogeton crispus",
"Butomus umbellatus",
"Lemna turionifera",
"Hottonia palustris",
"Hippuris vulgaris",
"Callitriche cophocarpa",
"Nymphaea candida",
"Pistia stratiotes",
"Potamogeton pusillus",
"Azolla filiculoides",
"Sagittaria latifolia",
"Sagittaria sagittifolia",
"Nymphoides peltata",
"Potamogeton berchtoldii",
"Potamogeton natans",
"Utricularia vulgaris",
"Utricularia intermedia",
"Callitriche obtusangula",
"Elodea canadensis",
"Zannichellia palustris",
"Wolffia arrhiza",
"Eleocharis acicularis",
"Menyanthes trifoliata",
"Potamogeton gramineus")
bb <- DT2.1 %>%
as_tibble() %>%
filter(PlotObservationID %in% mydata$RELEVE_NR) %>%
mutate(wetsp=species %in% wetland.species) %>%
group_by(PlotObservationID) %>%
summarize(wet.cover=sum(Relative.cover*wetsp), rich=n()) %>%
filter(wet.cover>=.50) %>%
pull(PlotObservationID)
mydata.R2 <- mydata %>%
filter(!RELEVE_NR %in% bb) %>%
filter(!RELEVE_NR %in% rejects.vegbank)
mydata <- mydata.R2
save(mydata, file = "../sPlot/_input/Mydata_global_NatCommR2.RData")
# check species in species poor plots
aa2 <- mydata.R2 %>%
filter(rich.complete<3) %>%
filter(plants_recorded=="complete") %>%
pull(RELEVE_NR)
DT2.1 %>%
as_tibble() %>%
dplyr::filter(PlotObservationID %in% aa2) %>%
count(species) %>%
arrange(desc(n))