-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03_OutputTables.R
50 lines (33 loc) · 2.79 KB
/
03_OutputTables.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
## Set up output tables
#This is in a separate file because if loop through species fails, don't want to re-write these files and delete everything that has already been done. Can then just re-start the loop at the next species, and keep going.
## Create .csv file for indices
indices.csv <- as.data.frame(matrix(data = NA, nrow = 1, ncol = 15, byrow = FALSE,
dimnames = NULL))
names(indices.csv) <- c("results_code", "version", "area_code", "season", "period", "species_code", "species_id", "year", "index", "stderr", "stdev", "upper_ci", "lower_ci", "LOESS_index", "trend_index")
write.table(indices.csv, file = paste(out.dir,
site, "_AnnualIndices",".csv", sep = ""),
row.names = FALSE, append = FALSE, quote = FALSE, sep = ",")
## Create .csv file for trends
trends.csv <- as.data.frame(matrix(data = NA, nrow = 1, ncol = 39,
byrow = FALSE, dimnames = NULL))
names(trends.csv) <- c("results_code", "version", "area_code", "season", "period", "species_code", "species_id", "years", "year_start", "year_end", "trnd", "lower_ci", "upper_ci", "index_type", "stderr", "model_type", "model_fit", "percent_change", "percent_change_low", "percent_change_high", "prob_decrease_0", "prob_decrease_25", "prob_decrease_30", "prob_decrease_50", "prob_increase_0", "prob_increase_33", "prob_increase_100", "suitability", "precision_num", "precision_cat", "coverage_num", "coverage_cat", "sample_size", "sample_size_units", "prob_LD", "prob_MD", "prob_LC", "prob_MI", "prob_LI")
#Endpoint Trends
write.table(trends.csv, file = paste(out.dir,
site, "_TrendsEndpoint", ".csv", sep = ""),
row.names = FALSE, append = FALSE, quote = FALSE, sep = ",")
#Slope Trends
write.table(trends.csv, file = paste(out.dir,
site, "_TrendsSlope", ".csv", sep = ""),
row.names = FALSE, append = FALSE, quote = FALSE, sep = ",")
## Create .csv file for dispersion stat
dispersion.csv <- as.data.frame(matrix(data = NA, nrow = 1, ncol = 3, byrow = FALSE,
dimnames = NULL))
names(dispersion.csv) <- c("area_code", "SpeciesCode", "dispersion")
write.table(dispersion.csv, file = paste(out.dir, site, "_DispersionStat.csv", sep = ""),
row.names = FALSE, append = FALSE, quote = FALSE, sep = ",")
## Create .csv file for DIC and WIC scores
model.csv <- as.data.frame(matrix(data = NA, nrow = 1, ncol = 4, byrow = FALSE,
dimnames = NULL))
names(model.csv) <- c("ModelType", "DIC", "WIC", "SpeciesCode")
write.table(model.csv, file = paste(out.dir, site, "ModelComparison.csv", sep = ""),
row.names = FALSE, append = FALSE, quote = FALSE, sep = ",")