Commit d6a90e5e authored by Gwen Iacona's avatar Gwen Iacona

updated simulated intermediary datafiles following updata to raw data....

updated simulated intermediary datafiles following updata to raw data. AllPPPOutput is now the version described in Gerber et al, 2018.

Slight code updates to functions that created the simulated files so they work with the updated raw dataset.

"app_noReporteR" contains slight code updates to run shiny without the depreciated packages. These packages need to be updated to a different package to regain the report printing functionality.
parent 85516601
Pipeline #1074 failed with stages
in 13 seconds
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
......@@ -39,7 +39,7 @@ for (method in c("CE", "CEs", "CEw", "CE1", "CE12")) {
# Set max budget to 600 million leaves out 2 plans (2-Amphibians-286, 46-Birds-12)
# but each are so high cost (>2 billion) they too greatly skew plots
# A 200,000 cost step creates a good plot in short time
out <- data.frame(Budget=seq(200000, 600000000, by=200000),
out <- data.frame(Budget=seq(200000, 6000000000, by=200000),
NPlansPossible=NA,
NPlansIncluded=NA,
NSppIncluded=NA,
......@@ -67,7 +67,9 @@ for (method in c("CE", "CEs", "CEw", "CE1", "CE12")) {
# Second identify the possible plans that are actually chosen
# Ths uses the custom function IncExcByBudget which classifies plans according to
# an allocation method (National, Regional, or Taxa)
# an allocation method (National, Regional, or Taxa) # turn on the appropriate one.
# tmp_included <- IncExcByBudget(tmp_possible, AnnBudget=budget, SplitLvl="National")
# tmp_included <- IncExcByBudget(tmp_possible, AnnBudget=budget, SplitLvl="Regional")
tmp_included <- IncExcByBudget(tmp_possible, AnnBudget=budget, SplitLvl="Taxa")
# Gather desired summary statistics from the included plans
......@@ -94,8 +96,15 @@ for (method in c("CE", "CEs", "CEw", "CE1", "CE12")) {
}
#saveRDS(budgetSimList, "C:/P_SESYNCapp/RecoveryExplorer/Data/National_budgetSimList.rds")
#saveRDS(regional_budgetSimList, "C:/P_SESYNCapp/RecoveryExplorer/Data/Taxa_regional_budgetSimList.rds")
# turn on the appropriate one
#saveRDS(budgetSimList, "./Data/National_budgetSimList.rds")
#saveRDS(budgetSimList, "./Data/Regional_budgetSimList.rds")
saveRDS(budgetSimList, "./Data/Taxa_budgetSimList.rds")
# turn on the appropriate one
#saveRDS(regional_budgetSimList, "./Data/National_regional_budgetSimList.rds")
#saveRDS(regional_budgetSimList, "./Data/Regional_regional_budgetSimList.rds")
saveRDS(regional_budgetSimList, "./Data/Taxa_regional_budgetSimList.rds")
# These were code to check the data outputs for logical consistency
......@@ -121,6 +130,6 @@ for (method in c("CE", "CEs", "CEw", "CE1", "CE12")) {
# geom_line(data=budgetSimList[["CEw"]], aes(x=Budget, y=NSppIncluded), col="red")+
# geom_line(data=budgetSimList[["CE1"]], aes(x=Budget, y=NSppIncluded), col="magenta")+
# geom_line(data=budgetSimList[["CE12"]], aes(x=Budget, y=NSppIncluded), col="brown")+
# scale_x_continuous(limits=c(0,2000000))+
# scale_x_continuous(limits=c(0,5000000))+
# scale_y_continuous(limits=c(0,500))
#
......@@ -41,7 +41,9 @@
library(readr)
#raw <- read_csv(file="C:/P_SESYNCapp/RecoveryExplorer/Data/AllPPPOutput2.csv")
raw <- read_csv(file="Data_All/AllPPPOutput2.csv")
#raw <- read_csv(file="Data_All/AllPPPOutput2.csv")
raw <- read_csv(file="Data/RawData/AllPPPOutput.csv") # updated datafile, GI 9/26/18
# There are some Inf values - These arise due to zero costs for recovery in denominator of efficiency algorithms. Some zeros may be real, but others are inconsistent with other data in the recovery plans. Any species with Inf values must be removed when running visualizations.
......@@ -64,8 +66,8 @@ for (i in 1:nrow(raw)){
# 2-Amphibian-286 cost is $10,404,766,154 (2.2 billion per year estimated)
# 46-Birds-12 cost is $7,533,046,675 (2.5 billion per year)
# These could later be added back in if the cost estimates were verified.
raw <- raw[-which(raw$MaxYearCost==2527914514),]
raw <- raw[-which(raw$MaxYearCost==2204602673),]
#raw <- raw[-which(raw$MaxYearCost==2527914514),] # GI 9/26/18 - I left these in because they are for large multispecies recovery plans and seem legit
#raw <- raw[-which(raw$MaxYearCost==2204602673),]
library(dplyr)
......@@ -74,8 +76,8 @@ library(magrittr)
# Create the wide version of the data
datWIDE <- raw %>%
dplyr::select(RID = row, NID = unique_plan_num, TID = unique_id,
Title = plan_title, SpeciesInPlan = SpeciesInPlan,
dplyr::select(RID = X1, TID = unique_id, # GI 9/26/18 took out plan number and title. Hopefully not needed anywhere
SpeciesInPlan = SpeciesInPlan,
Taxa = taxa_code_text, Region = Responsible_region,
Cost = Co, Benefit = B, Success = S, Weight = W,
CE=CE, CEs=CEs, CEw=CEw, CE1=CE1, CE12=CE12, everything()) %>%
......@@ -100,11 +102,11 @@ datWIDE <- raw %>%
#Create the long version of the data - this version is the primary data table called from in the Shiny app
datLONG <- raw %>%
dplyr::select(RID = row, NID = unique_plan_num, TID = unique_id,
Title = plan_title, SpeciesInPlan = SpeciesInPlan,
Taxa = taxa_code_text, Region = Responsible_region,
Cost = Co, Benefit = B, Success = S, Weight = W,
CE=CE, CEs=CEs, CEw=CEw, CE1=CE1, CE12=CE12, everything()) %>%
dplyr::select(RID = X1, TID = unique_id, # GI 9/26/18 took out plan number and title. Hopefully not needed anywhere
SpeciesInPlan = SpeciesInPlan,
Taxa = taxa_code_text, Region = Responsible_region,
Cost = Co, Benefit = B, Success = S, Weight = W,
CE=CE, CEs=CEs, CEw=CEw, CE1=CE1, CE12=CE12, everything()) %>%
# Add text region names
dplyr::mutate(RegionName = plyr::mapvalues(Region, c(1:8), c("Pacific", "Southwest", "Midwest", "Southeast", "Northeast", "Mountain Prairie", "Alaska", "Pacific Southwest"))) %>%
# Reshape to long format using CE method as new column
......@@ -117,5 +119,5 @@ datLONG <- raw %>%
dplyr::ungroup()
#write_csv(datLONG, path="C:/P_SESYNCapp/RecoveryExplorer/Data/TidyPPPOutput_LONG.csv")
#write_csv(datWIDE, path="C:/P_SESYNCapp/RecoveryExplorer/Data/TidyPPPOutput_WIDE.csv")
#write_csv(datLONG, path="./Data/TidyPPPOutput_LONG.csv")
#write_csv(datWIDE, path="./Data/TidyPPPOutput_WIDE.csv")
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment