-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustom_estimates_extraction.R
99 lines (64 loc) · 2.09 KB
/
Custom_estimates_extraction.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
## custom data extraction for a selected species (or list of species)
##
##
#
#
species_sel <- c("Grasshopper Sparrow")
outname <- "GRSP"# must supply meaningful file name suffix for output files
YYYY <- 2022
library(bbsBayes2)
library(tidyverse)
sp_list <- readRDS("species_list.rds") %>%
filter(model == TRUE)
trends <- readRDS(paste0("Website/All_BBS_Trends_",YYYY,".rds"))
indices <- readRDS(paste0("Website/All_BBS_Full_Indices_",YYYY,".rds"))
indices_smooth <- readRDS(paste0("Website/All_BBS_Smoothed_Indices_",YYYY,".rds"))
tr <- NULL
i <- NULL
ism <- NULL
for(sp_sel in species_sel){
tr <- trends %>%
filter(species == sp_sel) %>%
bind_rows(.,tr)
i <- indices %>%
filter(species == sp_sel) %>%
bind_rows(.,i)
ism <- indices_smooth %>%
filter(species == sp_sel) %>%
bind_rows(.,ism)
}
write_excel_csv(tr,
paste0("temp/custom_output/trends_",outname,".csv"))
write_excel_csv(i,
paste0("temp/custom_output/annual_indices_",outname,".csv"))
write_excel_csv(ism,
paste0("temp/custom_output/smoothed_annual_indices_",outname,".csv"))
# Regional ----------------------------------------------------------------
reg_sel <- c("NB")
outname <- reg_sel# must supply meaningful file name suffix for output files
YYYY <- 2022
library(bbsBayes2)
library(tidyverse)
trends <- readRDS(paste0("Website/All_BBS_Trends_",YYYY,".rds"))
indices <- readRDS(paste0("Website/All_BBS_Full_Indices_",YYYY,".rds"))
indices_smooth <- readRDS(paste0("Website/All_BBS_Smoothed_Indices_",YYYY,".rds"))
tr <- NULL
i <- NULL
ism <- NULL
for(reg in reg_sel){
tr <- trends %>%
filter(region == reg) %>%
bind_rows(.,tr)
i <- indices %>%
filter(region == reg) %>%
bind_rows(.,i)
ism <- indices_smooth %>%
filter(region == reg) %>%
bind_rows(.,ism)
}
write_excel_csv(tr,
paste0("temp/custom_output/trends_",outname,".csv"))
write_excel_csv(i,
paste0("temp/custom_output/annual_indices_",outname,".csv"))
write_excel_csv(ism,
paste0("temp/custom_output/smoothed_annual_indices_",outname,".csv"))