Chapter 2 Model Input Generation

2.1 Generate inputs for bioenergetics modeling, 2015-2016 inputs

The following files are required as inputs for an individual growth simulation in Fishbioenergetics 4.0:

  1. Temperature.csv; cols: day (DOY), temperature (C)

  2. Predator.csv; cols: day (DOY), predator (j/g)

  3. Prey.csv; cols: day (DOY), diet1, diet2, diet3… (energy densities)

  4. Indigestible_Prey.csv, cols: day (DOY), diet1, diet2, diet3… (proportion indigestable)

  5. Diet_Prop.csv; cols: day (DOY), diet1, diet2, diet3… (diet proportions)

In this section, we will generate input files using observed data from the 2015 and 2016 field seasons for individual cohorts (individual year, river, species, and age; e.g. “2015 Beaver Creek Age 1 Coho”).


2.1.1 Temperature

We used daily mean water temperature inputs from each site as model inputs.

Show/Hide Code used prepare water temperature data inputs from 2015-2016 field observations

# import daily mean temperature summaries
# originally from markdown document "season_temp_stats_v2.Rmd"
daily_mean_temps <- read.csv("other/inputs/temperature/observed_water_temp/daily_temp_metrics.csv") %>%
  select(Stream_Name,Site,year,Date,doy,daily_avg_temp) %>% 
  rename(site = Site) %>%
  transform(year = as.factor(year),
            Date = as.Date(Date))


2.1.2 Diet Inputs

In the originally submitted manuscript, we used estimated dry mass values of prey items collected in gastric lavage samples, as executed below:

Show/Hide Code used prepare original fish diet data inputs from 2015-2016 observations (e.g. diet data in previous submission to TAFS)


#########################
#                       #
# B.) Diet Input        #
#                       #
#########################

# process 2015 & 2016 data simultaneously
# arrange to identical dataframe structures then combine before proceeding

# 1.) Import and arrange data

# 2015 Diet Data: Import & Arrange

#create objects from overall diet data google sheets
SCTC2015 <- "other/inputs/diet_size_other/2015 EPSCoR SCTC.xlsx"
SCTC2016 <- "other/inputs/diet_size_other/2016_EPSCoR_Aquatic_Ecology_Database.xlsx"

# read in worksheets containing diet data
diet15 <- read_excel(SCTC2015, sheet = "2015 Diet Contents Data") %>% 
  select(Sample.ID,
         Fish_Species,
         Sample.Event,
         sample.event.num,
         River,
         Reach,
         Site,
         Sample_Date,
         Prey_Type_Used,
         PreyCategory,
         Quantity,
         Total_Prey_Dry_Mass_mg) %>%
  mutate(year = "2015") %>%
  transform(sample.event.num = as.integer(sample.event.num),
            Quantity = as.numeric(Quantity),
            Total_Prey_Dry_Mass_mg = as.numeric(Total_Prey_Dry_Mass_mg))     # columns import as character for some reason unless specified! (weird but innocuous quirk)
  

diet16 <- read_excel(SCTC2016, sheet = "2016 Diet Contents Data") %>%
  select(Sample.ID,
         Fish_Species,
         Sample.Event,
         sample.event.num,
         River,
         Reach,
         Site,
         Sample_Date,
         Prey_Type_Used,
         PreyCategory,
         Quantity,
         Total_Prey_Dry_Mass_mg) %>%
  mutate(year = "2016") %>%
  transform(sample.event.num = as.integer(sample.event.num))
  
# combine 2015 and 2016 diet data
diet <- bind_rows(diet15, diet16)

# finalize structure of diet data
diet <- diet %>%  
  #rename needed columns  
  rename(sample.id = Sample.ID,
         spp = Fish_Species,
         sample.event = Sample.Event,
         event.num = sample.event.num,
         river = River,
         reach = Reach,
         site = Site,
         date = Sample_Date,
         prey = Prey_Type_Used,
         preycat = PreyCategory,
         quantity = Quantity,
         dm_mg = Total_Prey_Dry_Mass_mg) %>%
  
  #select desired columns
  select(sample.id,
         spp,
         sample.event,
         event.num,
         river,
         reach,
         site,
         date,
         year,
         prey,
         preycat,
         quantity,
         dm_mg) %>%
  
  #filter out non-diet samples and blank data
  filter(site!="DR1",
         !is.na(spp),
         !is.na(sample.event),
         !is.na(prey),
         !is.na(dm_mg),
         !is.na(quantity),
         !is.na(event.num)) %>%
  
  #transform columns to desired classes
  transform(dm_mg = as.numeric(dm_mg),
            sample.event = as.factor(sample.event),
            event.num = as.factor(event.num),
            date = mdy(date),
            spp = as.factor(spp),
            quantity = as.numeric(quantity),
            preycat = as.factor(preycat))  %>%
  mutate(season = fct_recode(event.num,         #code sampling events as seasons
                             "Early Summer"= "1", 
                             "Mid-Summer" = "2",
                             "Late Summer" = "3",
                             "Fall" = "4")) 

# save to local directory
write.csv(diet,"other/outputs/diet_v1.csv",row.names = F)

rm(diet15,diet16)


At this stage of analysis all prey items have an estimated dry mass value, which we acquired by measuring each item’s length and applying the formula W = aL^b, where “a” and “b” are parameters derived from the literature. These calculations of estimated dry mass values are available for download below:

Download Original Version of Diet Dry Mass Inputs (v1.0)


However, to use these prey item mass values as inputs in our bioenergetics models, we need them in wet weight rather than dry mass. The original manuscript submitted to TAFS erroneously used dry weights.

To perform this needed transformation from dry mass to wet mass of prey items, we will apply wet/dry ratio values from the manuscript McCarthy 2009, along with four other literature sources. The downloadable table below summarises these wet/dry mass conversion and energy density values.


Download dry/wet mass conversion values and energy densities of prey item categories.


Show/Hide Code used prepare revised fish diet data inputs from 2015-2016 observations (e.g. diet data being converted to wet mass inputs)


# General approach:
# We will generate and export a table of unique prey types (n = 127), then for each type manually assign one of the twelve prey type categories from McCarthy et al 2009 (+ several other lit sources)
# generate csv of unique prey types
unique_prey <- data.frame(unique(diet$prey)) %>%
  clean_names()
write.csv(unique_prey,"other/outputs/diet/mass_conversion/prey_types.csv",row.names = F)

# using the "prey_types.csv" file generated above, we will manually generate an excel file pairing each prey item with a category that has a known dry mass conversion value. 

# We will then join the dry mass conversion values back to the full diet data table

# read in dry mass conversion values
dm_convert_prey_types <- read_excel("other/outputs/diet/mass_conversion/prey_types_manual_edit.xlsx", sheet = "prey_types", skip = 1) %>%
  select(-notes)

dm_convert_vals <- read_excel("other/outputs/diet/mass_conversion/prey_types_manual_edit.xlsx", sheet = "data_validation") %>%
  filter(!is.na(prey_type))

dm_convert_vals <- left_join(dm_convert_prey_types,dm_convert_vals,by = "prey_type") %>%
  filter(!is.na(wet_dry_ratio)) %>%
  select(-notes) %>%
  rename(prey = unique_diet_prey)

# join dry mass conversion values (by prey type) to overall diet data set
diet <- left_join(diet,dm_convert_vals,by = "prey") %>%
  filter(!is.na(wet_dry_ratio)) 

# create new column of wet mass for individual prey items
diet %<>% mutate(wm_mg = dm_mg / wet_dry_ratio)

# summarise wet mass by diet category
#diet %<>%
 # select(-preycat) %>%
  #group_by(river,spp,###AGE diet,PreyCategory_ED,energy_density_jg) %>%
  #summarise(sum_wm_mg = sum(wm_mg))

# convert wet masses to diet category proportions
# and create column for summed wet mass of all prey categories
#wm_sum_tot <- diet %>%
 # ungroup() %>%
#  summarise(tot_sum_wm_mg = sum(sum_wm_mg)) %>%
 # as.numeric()

#z <- diet %>%
#  mutate(tot_sum_wm_mg = wm_sum_tot) %>%
#  mutate(diet_wm_prop = sum_wm_mg / tot_sum_wm_mg) %>%
#  select(PreyCategory_ED,diet_wm_prop) %>%
#  pivot_wider()

# only categories not matching are non-diet items (empty, destroyed, bait, etc)

# next : check out energy density tabel from v1 to see less granular version of preycat


## at this step, we need to convert prey dry mass in to wet mass and use that for the input

# what we originally did: prey length --> dm
# what we need to do: prey length --> dm --> wm

## reviewer 2: "convert each of the major prey categories into wet mass proportions (i.e., divide by proportion dry weight)". proportion of what?

### plan: continue prepping input files, return to here when dm --> wm conversion process clearer

# create prey categorization scheme specific to bioenergetics modeling purposes
# -import from google sheet "EPSCoR_SCTC_Prey_Energy_Densities" and mutate new column to diet data
# -this sheet also contains energy density assignments, which must be manually input in "fishbioenergetics.r"
# at a later step.



# remove temporary objects
#rm(diet15,diet16,ED)


At this stage, we now are using estimated wet weights for each diet item from each gastric lavage sample.


2.1.3 Fish size and age

We will import fish size and age, then for those fish from which we collected gastric lavage samples, associate each fish with its own wet mass diet data.

Show/Hide Code used prepare fish age and size data inputs from 2015-2016 observations


# NOTE ON AGE STRUCTURE 3/28/18
# This script originally imported google sheet titled "all_fish_ages.csv", which contained results output from the "fish_ages_all.R" script.  The "fish_ages_all.R" script used methods described in Ch. 5 of Ogle 2016 ("Introductory fisheries analyses with R") to age all captured fish from a subset of fish scale samples.  Resultant csv file was copied to the google sheet referenced here.

# Further consideration has determined that using age-length keys for this project may not best serve its interests.  In the column "Age_manual2" imported in this chunk, age thresholds were identified visually as described in "fish_age_structure.R".  

# ID googlesheet with fish age data (3/28/18: no longer in use)
#fish_ages <- gs_title("all_fish_ages.csv") 
#Sys.sleep(6)

# read in desired worksheet 2015
fish_ages15 <- read_excel(SCTC2015, sheet = "C 2015 Diet & LW Data") %>%
  select(river,sample.id,sample.event,spp,Weight_g,Length_mm,Age_manual2,sample.event.num,`Date...41`,`Site ID`,reach_name) %>%
  mutate(season = fct_recode(as.factor(sample.event.num), #code sampling events as seasons
                             "Early Summer"="1", 
                             "Mid-Summer" = "2",
                             "Late Summer" ="3")) %>%
  rename(wt_g = Weight_g,
         len_mm = Length_mm,
         age = Age_manual2,
         Hydrologic.Segment = reach_name) %>%
  transform(`Date...41` = anydate(`Date...41`)) %>%
  rename(Date = `Date...41`) %>%
  # filter out all species except Chinook and Coho
  filter(spp %in% c("Coho", "Chinook")) %>% 
  transform(wt_g = as.double(wt_g))


# read in desired worksheet 2016
fish_ages16 <- read_excel(SCTC2016, sheet = "C 2016 Diet & LW Data") %>%
  select(river,sample.id,sample.event,spp,Weight_g,Length_mm,Age_manual2,sample.event.num,Date,`Site ID`,reach_name) %>%
  mutate(season = fct_recode(as.factor(sample.event.num),         #code sampling events as seasons
                             "Early Summer"="1", 
                             "Mid-Summer" = "2",
                             "Late Summer" ="3",
                             "Fall" ="4")) %>%
  rename(wt_g = Weight_g,
         len_mm = Length_mm,
         age = Age_manual2,
         Hydrologic.Segment = reach_name) %>%
  transform(Date = anydate(Date),
            wt_g = as.numeric(wt_g)) %>%
  filter(spp %in% c("Coho", "Chinook")) # filter out all species except Chinook and Coho


#join 2015 and 2016 data
fish_ages <- bind_rows(fish_ages15,fish_ages16)

rm(fish_ages15,fish_ages16)

#prep dataframe containing age data
fish_ages <- fish_ages %>% 
  separate(sample.event, c("reach","year","sample.event.num"), sep = "-", remove = F) %>%
  unite(river_spp, river, spp, remove = F, sep = " ") %>%
  # manually order appearance of seasons and rivers for plots
  transform(year = as.factor(year),
            river = factor(river, levels=c("Beaver Creek",
                                              'Russian River',
                                              'Ptarmigan Creek',
                                              'Kenai River')),
            season = factor(season, levels = c("Early Summer",
                                     "Mid-Summer",
                                     "Late Summer",
                                     "Fall")), 
            river_spp = as.factor(river_spp)) %>%
  mutate(river_spp = paste(river,"\n",spp)) %>%
  mutate(doy = yday(Date)) %>%
  filter(!is.na(age))
 # age 2 fish: this cohort is sparse and likely departing for the ocean.
 #filter(age != 2) 


# prep fish ages dataframe for later results table generation at end of this code chunk. Also save external csv for use in other script(s)
fish_ages1 <- fish_ages
write.csv(fish_ages,"other/outputs/all_fish_age_size.csv",row.names = F)

# reduce dataframe width
fish_ages %<>%
  select(sample.id,Date,age,wt_g,len_mm)

#eliminate duplicate rows
## this code was not hashtagged in the original analysis ...
#fish_ages <- unique(fish_ages)

# join fish ages date with diet data      
diet <- left_join(diet, fish_ages, by = c("sample.id"))  %>%
  select(-date)
# Generate table of fish size distribution by site

size_dist <- fish_ages1 %>%
  select(river,Hydrologic.Segment,spp,wt_g,len_mm,age) %>%
  filter(!is.na(wt_g),
         !is.na(len_mm)) %>%
  rename(reach = Hydrologic.Segment) %>%
  group_by(reach,river,spp,age) %>%
  summarise(mean_wt_g = round(mean(wt_g),1),
            stdev_wt_g = round(sd(wt_g),1),
            mean_len_mm = round(mean(len_mm),1),
            stdev_len_mm = round(sd(len_mm),1),
            mean_wt_g = paste0(mean_wt_g,"±",stdev_wt_g),
            mean_len_mm = paste0(mean_len_mm,"±",stdev_len_mm),
            n = n()) %>%
  select(-stdev_len_mm,-stdev_wt_g)

# use anti_join approach to remove all age 2 coho and age 1 chinook
anti_size_dist <- size_dist %>%
  filter(spp == "Coho" & age == 2 | spp == "Chinook" & age == 1)

# remove select spp/age cohorts via anti_join
size_dist <- anti_join(size_dist,anti_size_dist) %>%
  arrange(river,reach,spp,age)

# rename columns
size_dist %<>%
  rename(Reach = reach,
         Watershed = river,
         Species = spp,
         Age = age,
         `Mean Weight (g)` = mean_wt_g,
         `Mean Fork Length (mm)` = mean_len_mm,
         N = n)
  


Download table of observed fish weight/length distributions

Next, before proceeding with preparing diet proportions, we have a bit more work to do finalizing fish size and age data. For example, a few fish have diet data but no age. We will remove these fish.

2.1.3.0.1 How many fish have diet samples, but no age designation?

Show/Hide Code


# How many fish have diet samples, but no age designation?
diet_no_age <- diet %>%
  filter(is.na(age)) %>%
  distinct(sample.id)
diet_no_age <- nrow(diet_no_age)

#exclude these individuals
diet <- diet %>%
  filter(!is.na(age))

There are 7 fish with diet samples but no age manually assigned. These fish We will exclude these fish from analyses… for now, because we are running simulations seperately by age year/river/spp/age. Fish must have an age.


2.1.4 Define scale of diet and growth input pooling/segregation

We will group fish growth simulation inputs at the space/time scale of:

  • Individual River (pool data among sites within each river)

  • Species (segregate Chinook vs coho)

  • Fish age (age 0 vs 1)

  • Year (2015 or 2016)

Diet data, however is pooled among years (2015 and 2016) due to the heterogenous nature of this type of data.

For example, an individual cohort of fish could be “2015 Beaver Creek Age 1 Coho.” Diet data for this simulation is averaged from between 2015 and 2016.

Show/Hide Code


#create sum of pooled prey DM for each prey category by fish species and sample event 
wm_sum_by_event <- diet %>%
  
  # choose level of diet input segregation here
  group_by(
    #year,
    #Hydrologic.Segment,
    #season,
    river,
    spp,
    PreyCategory_ED,
    age) %>%
  summarise(sum(wm_mg)) %>%
  rename(wm_sum =`sum(wm_mg)`) %>%
  spread(PreyCategory_ED,wm_sum) %>%
  rowwise() %>%
  # create column for summed dry mass of all prey categories
  mutate(wm_tot = sum(InvertTerrestrial,
                      InvertAquatic_AqOrigin,
                      InvertTerrestrial_AqOrigin,
                      FishEggs,    
                      SalmonEggs, 
                      na.rm = TRUE)) %>%
  mutate(FishEggs = FishEggs/wm_tot,
         # change prey quantities to relative proportions by category
         InvertAquatic_AqOrigin = InvertAquatic_AqOrigin/wm_tot,  
         InvertTerrestrial = InvertTerrestrial/wm_tot,
         InvertTerrestrial_AqOrigin = InvertTerrestrial_AqOrigin/wm_tot,
         SalmonEggs = SalmonEggs/wm_tot) %>%
  rename(Stream_Name = river) %>%
  select(-wm_tot) %>%
  # show only 3 decimal places
  mutate(across(where(is.numeric), round, 3))


Download wet mass diet proportions by prey category for each fish cohort.


2.1.4.0.1 Define temporal extents of proposed simulations

We set the time period of each simulation as the period of day leading up from the prior field sampling event. For example, suppose that one field sampling event at Lower Beaver Creek occurred on June 1, 2015 and the next one on July 1, 2015. In this case the simulations for “Early Summer Lower Beaver Creek” runs for 30 days and uses diet inputs based on field data from June 1, 2015. Overall, we constrained the time period of our summer growth simulations to the period of days for which field data was available form both 2015 and 2016.

Show/Hide Code used to determine temporal length of fish growth simulations

# Define temporal extents of proposed simulations

# NOTE 1/22/18: this code also exists as a script at "/Users/bmeyer/Google Drive/Thesis/R Analysis/Thesis Analyses R Project/Overall_scripts_2015_2016/sampling_periods.R".  Attempted to just source("\path") this script in to the markdown document but, 'source' function prevents knitting through markdown for some reason.  

############
#
# 2015
#
###########

#read in specific worksheet containing fishing data
effort2015 <- read_excel(SCTC2015, sheet ="B Fishing Data",skip=2) %>%
  #rename needed columns  
  rename(site.id=Site_ID,
         sample.event=Sample_Event) %>%
  
  #select desired columns
  select(site.id,Reach,River,sample.event,sample.event.num,deploy_dt,collect_dt) %>%
  
  #filter out blanks
  filter(!is.na(sample.event)) %>%
  
  # transform columns to desired classes
  transform(site.id=as.factor(site.id),
            sample.event=as.factor(sample.event),
            sample.event.num=as.factor(sample.event.num)) 


###################
#
# 2016
#
###################

#read in specific worksheet containing fishing data
effort2016 <- read_excel(SCTC2016, sheet = "B Fishing Data",skip=2) %>%
  
  #rename needed columns  
  rename(site.id=Site_ID,
         sample.event=Sample_Event) %>%
  
  #select desired columns
  select(site.id,Reach,River,sample.event,sample.event.num,deploy_dt,collect_dt) %>%
  
  #filter our blanks
  filter(!is.na(sample.event)) %>%
  
  # transform columns to desired classes
  transform(site.id=as.factor(site.id),
            sample.event=as.factor(sample.event),
            sample.event.num=as.factor(sample.event.num)) 


# bind 2015 & 2016 data; format datetimes
effort <- bind_rows(effort2015,effort2016) %>%
  transform(collect_dt = anytime(collect_dt),
            deploy_dt = anytime(deploy_dt)) %>%
  mutate(year = year(collect_dt)) %>%
  mutate(site = paste(Reach,River)) %>%
  filter(site != "Upper Ptarmigan Creek")

rm(effort2015,effort2016)


######### Next: Simulation extents, sites not grouped by river; separate by site

# Define Temporal Extents of proposed simulations 

# "Simulation" temporal extent
# Time period from first date of each season to first date of following season

# prepare data to tibble form
sim_extents_by_site <- effort %>% 
  #select(-site.id) %>%
  group_by(River,site,year,sample.event,sample.event.num) %>% 
  nest() %>% 
  mutate(season.start = purrr:: map_dbl(data, ~min(.$deploy_dt)),
         season.end = purrr:: map_dbl(data, ~min(.$deploy_dt))
         ) %>%
  transform(season.start = anytime(season.start),
            season.end = anytime(season.end)) %>%
  arrange(site,year,sample.event) 

# prepare data such that end of one season is beginning of next
t15 <- sim_extents_by_site %>% 
  filter(year == 2015) %>%
  mutate(season.end_x = lead(season.end)) %>%
  select(-season.end) %>%
  arrange(River,year,sample.event)

t16 <- sim_extents_by_site %>% 
  filter(year == 2016) %>%
  mutate(season.end_x = lead(season.end)) %>%
  select(-season.end) %>%
  arrange(River,year,sample.event)

# prepare data such that final season of each year has duration of 30 days.
# 2015 had 3 seasons, 2016 had 4 seasons.

t_end15 <- t15 %>%
  filter(sample.event.num == 3) %>%
  mutate(season.end = season.start + days(30)) %>%
  select(-season.end_x)

t_end16 <- t16 %>%
  filter(sample.event.num == 4) %>%
  mutate(season.end = season.start + days(30)) %>%
  select(-season.end_x)

t_end15_1 <- t15 %>%
  filter(sample.event.num != 3) %>%
  rename(season.end = season.end_x)

t_end16_1 <- t16 %>%
  filter(sample.event.num != 4) %>%
  rename(season.end = season.end_x) %>%
  filter(sample.event != "MPC-2016-3")

# NOTE: there was no 4th visit in 2016 to Middle Ptarmigan Creek due to logistical reasons and low CPUE.  Final season temporal extent is manually assigned here
mpc_2016_3 <- t16 %>%
  filter(sample.event == "MPC-2016-3") %>%
  select(-season.end_x) %>%
  mutate(season.end = season.start + days(30))

# remove old version
rm(sim_extents_by_site)

# final version of simulation extents
sim_extents_by_site <- bind_rows(t_end15_1,t_end15,t_end16_1,t_end16,mpc_2016_3) %>%
  rename(Stream_Name = River,
         sim.start = season.start,
         sim.end = season.end) %>%
  transform(year = as.factor(year)) %>%
  mutate(season = fct_recode(as.factor(sample.event.num), #code sampling events as seasons
                             "Early Summer"="1", 
                             "Mid-Summer" = "2",
                             "Late Summer" ="3",
                             "Fall" = "4")) %>%
  select(-data) %>%
  mutate(days = round(sim.end - sim.start))

# remove temporary objects
rm(t_end15,t_end15_1,t_end16,t_end16_1,mpc_2016_3)


# match temporal extent of simulated diet proportion data to simulation date if it exists. 
diet_prop_seasons <- left_join(wm_sum_by_event,sim_extents_by_site) %>%
  transform(days = as.double(days))

# save seasonal diet proportions for later download
write.csv(diet_prop_seasons,"other/outputs/observed_diet_proportions.csv",row.names = F)

# extend diet props down length of season
# diet proportions are static throughout season for now, can consider other approaches later
sim_diet_days <- diet_prop_seasons[rep(seq_len(nrow(diet_prop_seasons)),diet_prop_seasons[,"days"]), ]

# add a row # ("SimDay") per row within each desired sim group, 
sim_diet_days <- sim_diet_days %>%
  mutate(sim_name = paste0(year,"_",
                           season,"_",
                           site,"_",
                           spp,"_",
                           "Age","_",
                           age)) %>%
  group_by(sim_name) %>%
  mutate(SimDay = row_number()) %>%
  mutate(Date = sim.start + days(SimDay)) %>%
  transform(Date = date(Date))


# join daily mean temperatures with diet proportions
sim_diet_days <- left_join(sim_diet_days,daily_mean_temps,by=c("Date","site","Stream_Name","year")) %>%
  rename(avg_temp = daily_avg_temp)



# arrange and rename columns to format identical as in "InputFileTemplate" for bioenergetics modeling
sim_diet_days <- sim_diet_days %>%
  rename(diet1 = FishEggs,
         diet2 = InvertAquatic_AqOrigin,
         diet3 = InvertTerrestrial,
         diet4 = InvertTerrestrial_AqOrigin,
         diet5 = SalmonEggs,
         Temp = avg_temp) %>%
  # add in blank columns 7-10 to match InputFileTemplate format
  mutate(diet6 = 0,
        diet7 = 0,
         diet8 = 0,
         diet9 = 0,
         diet10 = 0) %>%
  # select desired columns  
  select(Date,SimDay,Temp,
         contains("Diet"),
         sim_name,spp) %>%
  # ensure that list of dataframes and list of dataframe names match up order in next step
  arrange(sim_name) %>%
  # round decimals to two digits
  mutate_if(is.numeric, funs(round(., 1))) %>%
  # filter out simulation days with no temperature data; trim lengths of sims to days w/ sims
  filter(!is.na(Temp)) 
  
#replace all NA's with 0's
sim_diet_days[is.na(sim_diet_days)] <- 0

# arrange columns in desired order
sim_diet_days <- sim_diet_days %>%
  select(Date,SimDay,Temp,diet1,diet2,diet3,diet4,diet5,diet6,diet7,diet8,diet9,diet10,sim_name,spp)

# remove Date column from sim_diet_days
sim_diet_days <- sim_diet_days %>%
  select(-Date)


Download list of all unique fish growth simulationsDownload list of all observed diet proportions


How many unique simulations are included? There 58 unique simulations based on fish age, species, river, year and season.


2.1.5 Export files to be used as inputs in Fishbioenergetics 4.0


2.1.5.1 Diet proportion and water temperature csv file export prep

At this step, we will export csv files of diet proportions and water temperature unique to each iteration of year/season/river/species/age by day, each stored in the project directory folder named after the simulation. Each simulation will have a named folder containing the files “Diet_prop.csv” and “Temperature.csv.” Other input files are generated in subsequent steps.

Access bioenergetics simulation input files for download here:

Show/Hide Code used to prepare diet proportion and water temperature input files

# a.) export water temperature csv files

## select desired variables
watertemps <- sim_diet_days %>%
  select(SimDay,Temp,sim_name,spp) %>%
  rename(day = SimDay,
         temperature = Temp) %>%
#recreate grouping variable
  group_by(sim_name)

# create individual dataframes for each species
watertemps_coho <- watertemps %>%
  filter(spp == "Coho") %>%
  select(-spp)

watertemps_chnk <- watertemps %>%
  filter(spp == "Chinook") %>%
  select(-spp)

# split up all data in to lists of individual simulations by year, river, species, age, and season
watertemps_list_coho <- split.data.frame(watertemps_coho, watertemps_coho$sim_name)
watertemps_list_chnk <- split.data.frame(watertemps_chnk, watertemps_chnk$sim_name)

# remove column containing name of simulation from all objects in list
watertemps_list_coho <- lapply(watertemps_list_coho, function(x) x[!(names(x) %in% c("sim_name"))])
watertemps_list_chnk <- lapply(watertemps_list_chnk, function(x) x[!(names(x) %in% c("sim_name"))])


# b.) diet proportion csv file export prep

# export diet proportion csv files

## select desired variables
dietprops <- sim_diet_days %>%
  select(-Temp) %>%
  rename(day = SimDay) %>%
#recreate grouping variable
  group_by(sim_name)

# create individual dataframes for each species
dietprops_coho <- dietprops %>%
  filter(spp == "Coho") %>%
  select(-spp)

dietprops_chnk <- dietprops %>%
  filter(spp == "Chinook") %>%
  select(-spp)

# split up all data in to lists of individual simulations by year, river, species, age, and season
dietprops_list_coho <- split.data.frame(dietprops_coho, dietprops_coho$sim_name)
dietprops_list_chnk <- split.data.frame(dietprops_chnk, dietprops_chnk$sim_name)

# remove column containing name of simulation from all objects in list
dietprops_list_coho <- lapply(dietprops_list_coho, function(x) x[!(names(x) %in% c("sim_name"))])
dietprops_list_chnk <- lapply(dietprops_list_chnk, function(x) x[!(names(x) %in% c("sim_name"))])

# choose 2015 - 2016 simulations inputs location
sim_dir <- "other/FB4.1_2015_2016/inputs/"

# eliminate overall existing directory and contents if applicable
unlink(sim_dir, recursive = T)

# create overall directory destination for input files
dir.create(sim_dir)

# name subdirectory paths
chnk_dir <- paste0(sim_dir,"chnk/")
coho_dir <- paste0(sim_dir,"coho/")

# eliminate existing sub-directory and contents if applicable
unlink(chnk_dir, recursive = T)
unlink(coho_dir, recursive = T)

# create directory destinations for input files
dir.create(chnk_dir)
dir.create(coho_dir)


# c.) export chinook diet proportions to csv files

# get names of all simulations in a list
dietprops_names_chnk <- dietprops_chnk %>%
  select(sim_name) %>%
  distinct()
dietprops_names_chnk <- as.list(dietprops_names_chnk)

# create sub-directory for each simulation
## get simulation names
### chinook
dietprops_names_chnk <- as.data.frame(dietprops_names_chnk) %>%
  mutate(folder_dir = paste0(chnk_dir,sim_name),
         diet_csv_dir1 = paste0(chnk_dir,"Diet_prop_",sim_name,".csv"), 
         diet_csv_dir2 = paste0(folder_dir,"/","Diet_prop_",sim_name,".csv"),
         diet_csv_dir3 = paste0(folder_dir,"/","Diet_prop",".csv"))

# create individual folders named after each simulation
Map(dir.create,
    dietprops_names_chnk$folder_dir)
## $`other/FB4.1_2015_2016/inputs/chnk/2015_Early Summer_Lower Kenai River_Chinook_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2015_Mid-Summer_Middle Kenai River_Chinook_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Early Summer_Lower Kenai River_Chinook_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Early Summer_Lower Russian River_Chinook_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Lower Beaver Creek_Chinook_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Lower Kenai River_Chinook_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Middle Beaver Creek_Chinook_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Middle Kenai River_Chinook_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Upper Beaver Creek_Chinook_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Mid-Summer_Lower Beaver Creek_Chinook_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Mid-Summer_Lower Kenai River_Chinook_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Mid-Summer_Lower Ptarmigan Creek_Chinook_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Mid-Summer_Middle Beaver Creek_Chinook_Age_0`
## [1] TRUE

# write diet proportion csv files
mapply(write.table,row.names = F, sep=",",
       dietprops_list_chnk, file = paste0(chnk_dir,"Diet_prop","_", names(dietprops_list_chnk),".csv"))
## [[1]]
## NULL
## 
## [[2]]
## NULL
## 
## [[3]]
## NULL
## 
## [[4]]
## NULL
## 
## [[5]]
## NULL
## 
## [[6]]
## NULL
## 
## [[7]]
## NULL
## 
## [[8]]
## NULL
## 
## [[9]]
## NULL
## 
## [[10]]
## NULL
## 
## [[11]]
## NULL
## 
## [[12]]
## NULL
## 
## [[13]]
## NULL

# move output files from chnk directory to individual simulation folders
Map(file.rename,
    from = dietprops_names_chnk$diet_csv_dir1,
    to = dietprops_names_chnk$diet_csv_dir2)
## $`other/FB4.1_2015_2016/inputs/chnk/Diet_prop_2015_Early Summer_Lower Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Diet_prop_2015_Mid-Summer_Middle Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Diet_prop_2016_Early Summer_Lower Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Diet_prop_2016_Early Summer_Lower Russian River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Diet_prop_2016_Late Summer_Lower Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Diet_prop_2016_Late Summer_Lower Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Diet_prop_2016_Late Summer_Middle Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Diet_prop_2016_Late Summer_Middle Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Diet_prop_2016_Late Summer_Upper Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Diet_prop_2016_Mid-Summer_Lower Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Diet_prop_2016_Mid-Summer_Lower Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Diet_prop_2016_Mid-Summer_Lower Ptarmigan Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Diet_prop_2016_Mid-Summer_Middle Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE

# rename each diet proportion csv file as "Diet_prop" to prepare for input to FB4
Map(file.rename,
    from = dietprops_names_chnk$diet_csv_dir2,
    to = dietprops_names_chnk$diet_csv_dir3)
## $`other/FB4.1_2015_2016/inputs/chnk/2015_Early Summer_Lower Kenai River_Chinook_Age_0/Diet_prop_2015_Early Summer_Lower Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2015_Mid-Summer_Middle Kenai River_Chinook_Age_0/Diet_prop_2015_Mid-Summer_Middle Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Early Summer_Lower Kenai River_Chinook_Age_0/Diet_prop_2016_Early Summer_Lower Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Early Summer_Lower Russian River_Chinook_Age_0/Diet_prop_2016_Early Summer_Lower Russian River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Lower Beaver Creek_Chinook_Age_0/Diet_prop_2016_Late Summer_Lower Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Lower Kenai River_Chinook_Age_0/Diet_prop_2016_Late Summer_Lower Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Middle Beaver Creek_Chinook_Age_0/Diet_prop_2016_Late Summer_Middle Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Middle Kenai River_Chinook_Age_0/Diet_prop_2016_Late Summer_Middle Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Upper Beaver Creek_Chinook_Age_0/Diet_prop_2016_Late Summer_Upper Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Mid-Summer_Lower Beaver Creek_Chinook_Age_0/Diet_prop_2016_Mid-Summer_Lower Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Mid-Summer_Lower Kenai River_Chinook_Age_0/Diet_prop_2016_Mid-Summer_Lower Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Mid-Summer_Lower Ptarmigan Creek_Chinook_Age_0/Diet_prop_2016_Mid-Summer_Lower Ptarmigan Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Mid-Summer_Middle Beaver Creek_Chinook_Age_0/Diet_prop_2016_Mid-Summer_Middle Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE

# results: "Diet_prop.csv" exists in a named folder for each simulation


# d.) export chinook temperature data to csv files

# get names of all simulations in a list
watertemps_names_chnk <- watertemps_chnk %>%
  select(sim_name) %>%
  distinct()
watertemps_names_chnk <- as.list(watertemps_names_chnk)

# create sub-directory for each simulation
## get simulation names
### chinook
watertemps_names_chnk <- as.data.frame(watertemps_names_chnk) %>%
  mutate(folder_dir = paste0(chnk_dir,sim_name),
         diet_csv_dir1 = paste0(chnk_dir,"Temperature_",sim_name,".csv"), 
         diet_csv_dir2 = paste0(folder_dir,"/","Temperature_",sim_name,".csv"),
         diet_csv_dir3 = paste0(folder_dir,"/","Temperature",".csv"))

# create individual folders named after each simulation
Map(dir.create,
    watertemps_names_chnk$folder_dir)
## $`other/FB4.1_2015_2016/inputs/chnk/2015_Early Summer_Lower Kenai River_Chinook_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2015_Mid-Summer_Middle Kenai River_Chinook_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Early Summer_Lower Kenai River_Chinook_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Early Summer_Lower Russian River_Chinook_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Lower Beaver Creek_Chinook_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Lower Kenai River_Chinook_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Middle Beaver Creek_Chinook_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Middle Kenai River_Chinook_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Upper Beaver Creek_Chinook_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Mid-Summer_Lower Beaver Creek_Chinook_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Mid-Summer_Lower Kenai River_Chinook_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Mid-Summer_Lower Ptarmigan Creek_Chinook_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Mid-Summer_Middle Beaver Creek_Chinook_Age_0`
## [1] FALSE

# write temperature csv files
mapply(write.table,row.names = F, sep=",",
       watertemps_list_chnk, file = paste0(chnk_dir,"Temperature","_", names(watertemps_list_chnk),".csv"))
## [[1]]
## NULL
## 
## [[2]]
## NULL
## 
## [[3]]
## NULL
## 
## [[4]]
## NULL
## 
## [[5]]
## NULL
## 
## [[6]]
## NULL
## 
## [[7]]
## NULL
## 
## [[8]]
## NULL
## 
## [[9]]
## NULL
## 
## [[10]]
## NULL
## 
## [[11]]
## NULL
## 
## [[12]]
## NULL
## 
## [[13]]
## NULL

# move output files from chnk directory to individual simulation folders
Map(file.rename,
    from = watertemps_names_chnk$diet_csv_dir1,
    to = watertemps_names_chnk$diet_csv_dir2)
## $`other/FB4.1_2015_2016/inputs/chnk/Temperature_2015_Early Summer_Lower Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Temperature_2015_Mid-Summer_Middle Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Temperature_2016_Early Summer_Lower Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Temperature_2016_Early Summer_Lower Russian River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Temperature_2016_Late Summer_Lower Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Temperature_2016_Late Summer_Lower Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Temperature_2016_Late Summer_Middle Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Temperature_2016_Late Summer_Middle Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Temperature_2016_Late Summer_Upper Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Temperature_2016_Mid-Summer_Lower Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Temperature_2016_Mid-Summer_Lower Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Temperature_2016_Mid-Summer_Lower Ptarmigan Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/Temperature_2016_Mid-Summer_Middle Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE

# rename each temperature csv file as "Temperature" to prepare for input to FB4
Map(file.rename,
    from = watertemps_names_chnk$diet_csv_dir2,
    to = watertemps_names_chnk$diet_csv_dir3)
## $`other/FB4.1_2015_2016/inputs/chnk/2015_Early Summer_Lower Kenai River_Chinook_Age_0/Temperature_2015_Early Summer_Lower Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2015_Mid-Summer_Middle Kenai River_Chinook_Age_0/Temperature_2015_Mid-Summer_Middle Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Early Summer_Lower Kenai River_Chinook_Age_0/Temperature_2016_Early Summer_Lower Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Early Summer_Lower Russian River_Chinook_Age_0/Temperature_2016_Early Summer_Lower Russian River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Lower Beaver Creek_Chinook_Age_0/Temperature_2016_Late Summer_Lower Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Lower Kenai River_Chinook_Age_0/Temperature_2016_Late Summer_Lower Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Middle Beaver Creek_Chinook_Age_0/Temperature_2016_Late Summer_Middle Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Middle Kenai River_Chinook_Age_0/Temperature_2016_Late Summer_Middle Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Late Summer_Upper Beaver Creek_Chinook_Age_0/Temperature_2016_Late Summer_Upper Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Mid-Summer_Lower Beaver Creek_Chinook_Age_0/Temperature_2016_Mid-Summer_Lower Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Mid-Summer_Lower Kenai River_Chinook_Age_0/Temperature_2016_Mid-Summer_Lower Kenai River_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Mid-Summer_Lower Ptarmigan Creek_Chinook_Age_0/Temperature_2016_Mid-Summer_Lower Ptarmigan Creek_Chinook_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/chnk/2016_Mid-Summer_Middle Beaver Creek_Chinook_Age_0/Temperature_2016_Mid-Summer_Middle Beaver Creek_Chinook_Age_0.csv`
## [1] TRUE

# results: "Temperature.csv" exists in a named folder for each simulation



# e.) export coho diet proportions to csv files
# get names of all simulations in a list
dietprops_names_coho <- dietprops_coho %>%
  select(sim_name) %>%
  distinct()
dietprops_names_coho <- as.list(dietprops_names_coho)

# create sub-directory for each simulation
## get simulation names
dietprops_names_coho <- as.data.frame(dietprops_names_coho) %>%
  mutate(folder_dir = paste0(coho_dir,sim_name),
         diet_csv_dir1 = paste0(coho_dir,"Diet_prop_",sim_name,".csv"), 
         diet_csv_dir2 = paste0(folder_dir,"/","Diet_prop_",sim_name,".csv"),
         diet_csv_dir3 = paste0(folder_dir,"/","Diet_prop",".csv"))

# create individual folders named after each simulation
Map(dir.create,
    dietprops_names_coho$folder_dir)
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Lower Beaver Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Lower Ptarmigan Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Middle Beaver Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Middle Ptarmigan Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Middle Russian River_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Middle Russian River_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Upper Russian River_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Upper Russian River_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Lower Beaver Creek_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Lower Beaver Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Lower Kenai River_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Lower Ptarmigan Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Beaver Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Kenai River_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Ptarmigan Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Russian River_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Russian River_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Upper Russian River_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Lower Beaver Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Lower Ptarmigan Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Lower Russian River_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Middle Beaver Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Middle Russian River_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Upper Beaver Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Beaver Creek_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Beaver Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Kenai River_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Ptarmigan Creek_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Russian River_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Middle Beaver Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Middle Kenai River_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Middle Russian River_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Upper Beaver Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Upper Russian River_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Lower Beaver Creek_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Lower Beaver Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Lower Ptarmigan Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Lower Russian River_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Middle Beaver Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Middle Ptarmigan Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Middle Russian River_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Middle Russian River_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Upper Beaver Creek_Coho_Age_1`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Upper Russian River_Coho_Age_0`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Upper Russian River_Coho_Age_1`
## [1] TRUE

# write diet proportion csv files
mapply(write.table,row.names = F, sep=",",
       dietprops_list_coho, file = paste0(coho_dir,"Diet_prop","_", names(dietprops_list_coho),".csv"))
## [[1]]
## NULL
## 
## [[2]]
## NULL
## 
## [[3]]
## NULL
## 
## [[4]]
## NULL
## 
## [[5]]
## NULL
## 
## [[6]]
## NULL
## 
## [[7]]
## NULL
## 
## [[8]]
## NULL
## 
## [[9]]
## NULL
## 
## [[10]]
## NULL
## 
## [[11]]
## NULL
## 
## [[12]]
## NULL
## 
## [[13]]
## NULL
## 
## [[14]]
## NULL
## 
## [[15]]
## NULL
## 
## [[16]]
## NULL
## 
## [[17]]
## NULL
## 
## [[18]]
## NULL
## 
## [[19]]
## NULL
## 
## [[20]]
## NULL
## 
## [[21]]
## NULL
## 
## [[22]]
## NULL
## 
## [[23]]
## NULL
## 
## [[24]]
## NULL
## 
## [[25]]
## NULL
## 
## [[26]]
## NULL
## 
## [[27]]
## NULL
## 
## [[28]]
## NULL
## 
## [[29]]
## NULL
## 
## [[30]]
## NULL
## 
## [[31]]
## NULL
## 
## [[32]]
## NULL
## 
## [[33]]
## NULL
## 
## [[34]]
## NULL
## 
## [[35]]
## NULL
## 
## [[36]]
## NULL
## 
## [[37]]
## NULL
## 
## [[38]]
## NULL
## 
## [[39]]
## NULL
## 
## [[40]]
## NULL
## 
## [[41]]
## NULL
## 
## [[42]]
## NULL
## 
## [[43]]
## NULL
## 
## [[44]]
## NULL
## 
## [[45]]
## NULL

# move output files from coho directory to individual simulation folders
Map(file.rename,
    from = dietprops_names_coho$diet_csv_dir1,
    to = dietprops_names_coho$diet_csv_dir2)
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Early Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Early Summer_Lower Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Early Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Early Summer_Middle Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Early Summer_Middle Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Early Summer_Middle Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Early Summer_Upper Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Early Summer_Upper Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Mid-Summer_Lower Beaver Creek_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Mid-Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Mid-Summer_Lower Kenai River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Mid-Summer_Lower Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Mid-Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Mid-Summer_Middle Kenai River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Mid-Summer_Middle Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Mid-Summer_Middle Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Mid-Summer_Middle Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2015_Mid-Summer_Upper Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Early Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Early Summer_Lower Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Early Summer_Lower Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Early Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Early Summer_Middle Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Early Summer_Upper Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Late Summer_Lower Beaver Creek_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Late Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Late Summer_Lower Kenai River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Late Summer_Lower Ptarmigan Creek_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Late Summer_Lower Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Late Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Late Summer_Middle Kenai River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Late Summer_Middle Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Late Summer_Upper Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Late Summer_Upper Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Mid-Summer_Lower Beaver Creek_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Mid-Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Mid-Summer_Lower Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Mid-Summer_Lower Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Mid-Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Mid-Summer_Middle Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Mid-Summer_Middle Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Mid-Summer_Middle Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Mid-Summer_Upper Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Mid-Summer_Upper Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Diet_prop_2016_Mid-Summer_Upper Russian River_Coho_Age_1.csv`
## [1] TRUE

# rename each diet proportion csv file as "Diet_prop" to prepare for input to FB4
Map(file.rename,
    from = dietprops_names_coho$diet_csv_dir2,
    to = dietprops_names_coho$diet_csv_dir3)
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Lower Beaver Creek_Coho_Age_1/Diet_prop_2015_Early Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Lower Ptarmigan Creek_Coho_Age_1/Diet_prop_2015_Early Summer_Lower Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Middle Beaver Creek_Coho_Age_1/Diet_prop_2015_Early Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Middle Ptarmigan Creek_Coho_Age_1/Diet_prop_2015_Early Summer_Middle Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Middle Russian River_Coho_Age_0/Diet_prop_2015_Early Summer_Middle Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Middle Russian River_Coho_Age_1/Diet_prop_2015_Early Summer_Middle Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Upper Russian River_Coho_Age_0/Diet_prop_2015_Early Summer_Upper Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Upper Russian River_Coho_Age_1/Diet_prop_2015_Early Summer_Upper Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Lower Beaver Creek_Coho_Age_0/Diet_prop_2015_Mid-Summer_Lower Beaver Creek_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Lower Beaver Creek_Coho_Age_1/Diet_prop_2015_Mid-Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Lower Kenai River_Coho_Age_0/Diet_prop_2015_Mid-Summer_Lower Kenai River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Lower Ptarmigan Creek_Coho_Age_1/Diet_prop_2015_Mid-Summer_Lower Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Beaver Creek_Coho_Age_1/Diet_prop_2015_Mid-Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Kenai River_Coho_Age_0/Diet_prop_2015_Mid-Summer_Middle Kenai River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Ptarmigan Creek_Coho_Age_1/Diet_prop_2015_Mid-Summer_Middle Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Russian River_Coho_Age_0/Diet_prop_2015_Mid-Summer_Middle Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Russian River_Coho_Age_1/Diet_prop_2015_Mid-Summer_Middle Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Upper Russian River_Coho_Age_0/Diet_prop_2015_Mid-Summer_Upper Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Lower Beaver Creek_Coho_Age_1/Diet_prop_2016_Early Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Lower Ptarmigan Creek_Coho_Age_1/Diet_prop_2016_Early Summer_Lower Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Lower Russian River_Coho_Age_1/Diet_prop_2016_Early Summer_Lower Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Middle Beaver Creek_Coho_Age_1/Diet_prop_2016_Early Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Middle Russian River_Coho_Age_1/Diet_prop_2016_Early Summer_Middle Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Upper Beaver Creek_Coho_Age_1/Diet_prop_2016_Early Summer_Upper Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Beaver Creek_Coho_Age_0/Diet_prop_2016_Late Summer_Lower Beaver Creek_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Beaver Creek_Coho_Age_1/Diet_prop_2016_Late Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Kenai River_Coho_Age_0/Diet_prop_2016_Late Summer_Lower Kenai River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Ptarmigan Creek_Coho_Age_0/Diet_prop_2016_Late Summer_Lower Ptarmigan Creek_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Russian River_Coho_Age_0/Diet_prop_2016_Late Summer_Lower Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Middle Beaver Creek_Coho_Age_1/Diet_prop_2016_Late Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Middle Kenai River_Coho_Age_0/Diet_prop_2016_Late Summer_Middle Kenai River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Middle Russian River_Coho_Age_0/Diet_prop_2016_Late Summer_Middle Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Upper Beaver Creek_Coho_Age_1/Diet_prop_2016_Late Summer_Upper Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Upper Russian River_Coho_Age_0/Diet_prop_2016_Late Summer_Upper Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Lower Beaver Creek_Coho_Age_0/Diet_prop_2016_Mid-Summer_Lower Beaver Creek_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Lower Beaver Creek_Coho_Age_1/Diet_prop_2016_Mid-Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Lower Ptarmigan Creek_Coho_Age_1/Diet_prop_2016_Mid-Summer_Lower Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Lower Russian River_Coho_Age_0/Diet_prop_2016_Mid-Summer_Lower Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Middle Beaver Creek_Coho_Age_1/Diet_prop_2016_Mid-Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Middle Ptarmigan Creek_Coho_Age_1/Diet_prop_2016_Mid-Summer_Middle Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Middle Russian River_Coho_Age_0/Diet_prop_2016_Mid-Summer_Middle Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Middle Russian River_Coho_Age_1/Diet_prop_2016_Mid-Summer_Middle Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Upper Beaver Creek_Coho_Age_1/Diet_prop_2016_Mid-Summer_Upper Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Upper Russian River_Coho_Age_0/Diet_prop_2016_Mid-Summer_Upper Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Upper Russian River_Coho_Age_1/Diet_prop_2016_Mid-Summer_Upper Russian River_Coho_Age_1.csv`
## [1] TRUE

# results: "Diet_prop.csv" exists in a named folder for each simulation



# f.) export coho temperature data to csv files

# get names of all simulations in a list
watertemps_names_coho <- watertemps_coho %>%
  select(sim_name) %>%
  distinct()
watertemps_names_coho <- as.list(watertemps_names_coho)

# create sub-directory for each simulation
## get simulation names
watertemps_names_coho <- as.data.frame(watertemps_names_coho) %>%
  mutate(folder_dir = paste0(coho_dir,sim_name),
         diet_csv_dir1 = paste0(coho_dir,"Temperature_",sim_name,".csv"), 
         diet_csv_dir2 = paste0(folder_dir,"/","Temperature_",sim_name,".csv"),
         diet_csv_dir3 = paste0(folder_dir,"/","Temperature",".csv"))

# create individual folders named after each simulation
Map(dir.create,
    watertemps_names_coho$folder_dir)
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Lower Beaver Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Lower Ptarmigan Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Middle Beaver Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Middle Ptarmigan Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Middle Russian River_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Middle Russian River_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Upper Russian River_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Upper Russian River_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Lower Beaver Creek_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Lower Beaver Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Lower Kenai River_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Lower Ptarmigan Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Beaver Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Kenai River_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Ptarmigan Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Russian River_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Russian River_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Upper Russian River_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Lower Beaver Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Lower Ptarmigan Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Lower Russian River_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Middle Beaver Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Middle Russian River_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Upper Beaver Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Beaver Creek_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Beaver Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Kenai River_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Ptarmigan Creek_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Russian River_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Middle Beaver Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Middle Kenai River_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Middle Russian River_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Upper Beaver Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Upper Russian River_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Lower Beaver Creek_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Lower Beaver Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Lower Ptarmigan Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Lower Russian River_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Middle Beaver Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Middle Ptarmigan Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Middle Russian River_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Middle Russian River_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Upper Beaver Creek_Coho_Age_1`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Upper Russian River_Coho_Age_0`
## [1] FALSE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Upper Russian River_Coho_Age_1`
## [1] FALSE

# write temperature csv files
mapply(write.table,row.names = F, sep=",",
       watertemps_list_coho, file = paste0(coho_dir,"Temperature","_", names(watertemps_list_coho),".csv"))
## [[1]]
## NULL
## 
## [[2]]
## NULL
## 
## [[3]]
## NULL
## 
## [[4]]
## NULL
## 
## [[5]]
## NULL
## 
## [[6]]
## NULL
## 
## [[7]]
## NULL
## 
## [[8]]
## NULL
## 
## [[9]]
## NULL
## 
## [[10]]
## NULL
## 
## [[11]]
## NULL
## 
## [[12]]
## NULL
## 
## [[13]]
## NULL
## 
## [[14]]
## NULL
## 
## [[15]]
## NULL
## 
## [[16]]
## NULL
## 
## [[17]]
## NULL
## 
## [[18]]
## NULL
## 
## [[19]]
## NULL
## 
## [[20]]
## NULL
## 
## [[21]]
## NULL
## 
## [[22]]
## NULL
## 
## [[23]]
## NULL
## 
## [[24]]
## NULL
## 
## [[25]]
## NULL
## 
## [[26]]
## NULL
## 
## [[27]]
## NULL
## 
## [[28]]
## NULL
## 
## [[29]]
## NULL
## 
## [[30]]
## NULL
## 
## [[31]]
## NULL
## 
## [[32]]
## NULL
## 
## [[33]]
## NULL
## 
## [[34]]
## NULL
## 
## [[35]]
## NULL
## 
## [[36]]
## NULL
## 
## [[37]]
## NULL
## 
## [[38]]
## NULL
## 
## [[39]]
## NULL
## 
## [[40]]
## NULL
## 
## [[41]]
## NULL
## 
## [[42]]
## NULL
## 
## [[43]]
## NULL
## 
## [[44]]
## NULL
## 
## [[45]]
## NULL

# move output files from coho directory to individual simulation folders
Map(file.rename,
    from = watertemps_names_coho$diet_csv_dir1,
    to = watertemps_names_coho$diet_csv_dir2)
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Early Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Early Summer_Lower Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Early Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Early Summer_Middle Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Early Summer_Middle Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Early Summer_Middle Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Early Summer_Upper Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Early Summer_Upper Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Mid-Summer_Lower Beaver Creek_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Mid-Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Mid-Summer_Lower Kenai River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Mid-Summer_Lower Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Mid-Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Mid-Summer_Middle Kenai River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Mid-Summer_Middle Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Mid-Summer_Middle Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Mid-Summer_Middle Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2015_Mid-Summer_Upper Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Early Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Early Summer_Lower Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Early Summer_Lower Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Early Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Early Summer_Middle Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Early Summer_Upper Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Late Summer_Lower Beaver Creek_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Late Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Late Summer_Lower Kenai River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Late Summer_Lower Ptarmigan Creek_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Late Summer_Lower Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Late Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Late Summer_Middle Kenai River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Late Summer_Middle Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Late Summer_Upper Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Late Summer_Upper Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Mid-Summer_Lower Beaver Creek_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Mid-Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Mid-Summer_Lower Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Mid-Summer_Lower Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Mid-Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Mid-Summer_Middle Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Mid-Summer_Middle Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Mid-Summer_Middle Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Mid-Summer_Upper Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Mid-Summer_Upper Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/Temperature_2016_Mid-Summer_Upper Russian River_Coho_Age_1.csv`
## [1] TRUE

# rename each diet proportion csv file as "Temperature" to prepare for input to FB4
Map(file.rename,
    from = watertemps_names_coho$diet_csv_dir2,
    to = watertemps_names_coho$diet_csv_dir3)
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Lower Beaver Creek_Coho_Age_1/Temperature_2015_Early Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Lower Ptarmigan Creek_Coho_Age_1/Temperature_2015_Early Summer_Lower Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Middle Beaver Creek_Coho_Age_1/Temperature_2015_Early Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Middle Ptarmigan Creek_Coho_Age_1/Temperature_2015_Early Summer_Middle Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Middle Russian River_Coho_Age_0/Temperature_2015_Early Summer_Middle Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Middle Russian River_Coho_Age_1/Temperature_2015_Early Summer_Middle Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Upper Russian River_Coho_Age_0/Temperature_2015_Early Summer_Upper Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Early Summer_Upper Russian River_Coho_Age_1/Temperature_2015_Early Summer_Upper Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Lower Beaver Creek_Coho_Age_0/Temperature_2015_Mid-Summer_Lower Beaver Creek_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Lower Beaver Creek_Coho_Age_1/Temperature_2015_Mid-Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Lower Kenai River_Coho_Age_0/Temperature_2015_Mid-Summer_Lower Kenai River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Lower Ptarmigan Creek_Coho_Age_1/Temperature_2015_Mid-Summer_Lower Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Beaver Creek_Coho_Age_1/Temperature_2015_Mid-Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Kenai River_Coho_Age_0/Temperature_2015_Mid-Summer_Middle Kenai River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Ptarmigan Creek_Coho_Age_1/Temperature_2015_Mid-Summer_Middle Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Russian River_Coho_Age_0/Temperature_2015_Mid-Summer_Middle Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Middle Russian River_Coho_Age_1/Temperature_2015_Mid-Summer_Middle Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2015_Mid-Summer_Upper Russian River_Coho_Age_0/Temperature_2015_Mid-Summer_Upper Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Lower Beaver Creek_Coho_Age_1/Temperature_2016_Early Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Lower Ptarmigan Creek_Coho_Age_1/Temperature_2016_Early Summer_Lower Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Lower Russian River_Coho_Age_1/Temperature_2016_Early Summer_Lower Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Middle Beaver Creek_Coho_Age_1/Temperature_2016_Early Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Middle Russian River_Coho_Age_1/Temperature_2016_Early Summer_Middle Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Early Summer_Upper Beaver Creek_Coho_Age_1/Temperature_2016_Early Summer_Upper Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Beaver Creek_Coho_Age_0/Temperature_2016_Late Summer_Lower Beaver Creek_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Beaver Creek_Coho_Age_1/Temperature_2016_Late Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Kenai River_Coho_Age_0/Temperature_2016_Late Summer_Lower Kenai River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Ptarmigan Creek_Coho_Age_0/Temperature_2016_Late Summer_Lower Ptarmigan Creek_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Lower Russian River_Coho_Age_0/Temperature_2016_Late Summer_Lower Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Middle Beaver Creek_Coho_Age_1/Temperature_2016_Late Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Middle Kenai River_Coho_Age_0/Temperature_2016_Late Summer_Middle Kenai River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Middle Russian River_Coho_Age_0/Temperature_2016_Late Summer_Middle Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Upper Beaver Creek_Coho_Age_1/Temperature_2016_Late Summer_Upper Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Late Summer_Upper Russian River_Coho_Age_0/Temperature_2016_Late Summer_Upper Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Lower Beaver Creek_Coho_Age_0/Temperature_2016_Mid-Summer_Lower Beaver Creek_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Lower Beaver Creek_Coho_Age_1/Temperature_2016_Mid-Summer_Lower Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Lower Ptarmigan Creek_Coho_Age_1/Temperature_2016_Mid-Summer_Lower Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Lower Russian River_Coho_Age_0/Temperature_2016_Mid-Summer_Lower Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Middle Beaver Creek_Coho_Age_1/Temperature_2016_Mid-Summer_Middle Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Middle Ptarmigan Creek_Coho_Age_1/Temperature_2016_Mid-Summer_Middle Ptarmigan Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Middle Russian River_Coho_Age_0/Temperature_2016_Mid-Summer_Middle Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Middle Russian River_Coho_Age_1/Temperature_2016_Mid-Summer_Middle Russian River_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Upper Beaver Creek_Coho_Age_1/Temperature_2016_Mid-Summer_Upper Beaver Creek_Coho_Age_1.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Upper Russian River_Coho_Age_0/Temperature_2016_Mid-Summer_Upper Russian River_Coho_Age_0.csv`
## [1] TRUE
## 
## $`other/FB4.1_2015_2016/inputs/coho/2016_Mid-Summer_Upper Russian River_Coho_Age_1/Temperature_2016_Mid-Summer_Upper Russian River_Coho_Age_1.csv`
## [1] TRUE

# results: "Temperature.csv" exists in a named folder for each simulation


2.1.5.2 Other input files generation

Other input files required for bioenergetics simulations remain static throughout all simulations. These file types include:

  • Indigestable_Prey.csv

  • Pred_E.csv

  • Prey_E.csv

We will generate these files and place them within each simulation folder.

Show/Hide Code used to prepare static input files for bioenergtics simulations

# write the three constant Main Input files to local directory folder

## Indigestible prey
day <- c(1,365)
diet1 <- .03
diet2 <- .17
diet3 <- .17
diet4 <- .17
diet5 <-  0.3  
diet6 <- 0
diet7 <- 0
diet8 <- 0 
diet9 <- 0
diet10 <- 0

# collate to data frame
Indigestible_Prey <- data.frame(day,diet1,diet2,diet3,diet4,diet5,
                                diet6,diet7,diet8,diet9,diet10)

# create folder for static inputs
static_inputs_dir <- paste0(sim_dir,"Main_Inputs","/")
unlink(static_inputs_dir, recursive = T)
dir.create(static_inputs_dir)

# write file
write.csv(Indigestible_Prey,paste0(static_inputs_dir,"Indigestible_Prey.csv"), row.names = F)

  
## Pred_E.csv
predator <- 5000
# collate to data frame
Pred_E <- data.frame(day,predator)
# write file
write.csv(Pred_E, paste0(static_inputs_dir,"Pred_E.csv"), row.names = F)


## Prey_E.csv
### see sheet "EPSCoR_SCTC_Prey_Energy_Densities"
diet1 <- 5235 # FishEggs
diet2 <- 3365 # InvertAquatic_AqOrigin
diet3 <- 5250 # InvertTerrestrial
diet4 <- 4225 # InvertTerrestrial_AqOrigin
diet5 <- 9000 # SalmonEggs
diet6 <- 0 
diet7 <- 0
diet8 <- 0
diet9 <- 0
diet10 <- 0
  
Prey_E <- data.frame(day,diet1,diet2,diet3,diet4,diet5,
                     diet6,diet7,diet8,diet9,diet10)

write.csv(Prey_E, paste0(static_inputs_dir,"Prey_E.csv"), row.names = F)



####################################################################

## Place static value files in each simulation folder
## Approach: same as other csv exports; create list of dataframes and use mapply to export

## proceed by individual species and file type

# chinook - Indigestible Prey

# get master copy file directory for indigestible prey
ip_dir <- paste0(static_inputs_dir,"Indigestible_Prey.csv")

# Get list of folders in directory destination
z <- as.data.frame(list.dirs(path = chnk_dir)) 
z <- as.data.frame(z[-1, ], drop = F) 
colnames(z) <- "sim_dir"
z <- z %>%
  mutate(simx = str_replace(z$sim_dir,"//","/")) %>%
  select(-sim_dir) %>%
  mutate(sim_dir = paste0(simx,"/","Indigestible_Prey",".csv")) %>%
  select(-simx)
  
# write same csv file to all simulation sub-folders
Map(file.copy,
    from = ip_dir,
    to = z$sim_dir,
    overwrite = T)
## $`other/FB4.1_2015_2016/inputs/Main_Inputs/Indigestible_Prey.csv`
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE


# chinook - Pred_E.csv file export

# get master copy file directory for indigestible prey
pe_dir <- paste0(static_inputs_dir,"Pred_E.csv")

# Get list of folders in directory destination
z <- as.data.frame(list.dirs(path = chnk_dir)) 
z <- as.data.frame(z[-1, ], drop = F) 
colnames(z) <- "sim_dir"
z <- z %>%
  mutate(simx = str_replace(z$sim_dir,"//","/")) %>%
  select(-sim_dir) %>%
  mutate(sim_dir = paste0(simx,"/","Pred_E",".csv")) %>%
  select(-simx)
  
# write same csv file to all simulation sub-folders
Map(file.copy,
    from = pe_dir,
    to = z$sim_dir,
    overwrite = T)
## $`other/FB4.1_2015_2016/inputs/Main_Inputs/Pred_E.csv`
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
  


# chinook - Prey_E.csv export
# get master copy file directory for indigestible prey

pred_dir <- paste0(static_inputs_dir,"Prey_E.csv")

# Get list of folders in directory destination
z <- as.data.frame(list.dirs(path = chnk_dir)) 
z <- as.data.frame(z[-1, ], drop = F) 
colnames(z) <- "sim_dir"
z <- z %>%
  mutate(simx = str_replace(z$sim_dir,"//","/")) %>%
  select(-sim_dir) %>%
  mutate(sim_dir = paste0(simx,"/","Prey_E",".csv")) %>%
  select(-simx)
  
# write same csv file to all simulation sub-folders
Map(file.copy,
    from = pred_dir,
    to = z$sim_dir,
    overwrite = T)
## $`other/FB4.1_2015_2016/inputs/Main_Inputs/Prey_E.csv`
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE




# coho - Indigestible prey csv export

# get master copy file directory for indigestible prey
ip_dir <- paste0(static_inputs_dir,"Indigestible_Prey.csv")

# Get list of folders in directory destination
z <- as.data.frame(list.dirs(path = coho_dir)) 
z <- as.data.frame(z[-1, ], drop = F) 
colnames(z) <- "sim_dir"
z <- z %>%
  mutate(simx = str_replace(z$sim_dir,"//","/")) %>%
  select(-sim_dir) %>%
  mutate(sim_dir = paste0(simx,"/","Indigestible_Prey",".csv")) %>%
  select(-simx)
  
# write same csv file to all simulation sub-folders
Map(file.copy,
    from = ip_dir,
    to = z$sim_dir,
    overwrite = T)
## $`other/FB4.1_2015_2016/inputs/Main_Inputs/Indigestible_Prey.csv`
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE

# coho - Pred_E.csv export

# get master copy file directory for indigestible prey
pe_dir <- paste0(static_inputs_dir,"Pred_E.csv")

# Get list of folders in directory destination
z <- as.data.frame(list.dirs(path = coho_dir)) 
z <- as.data.frame(z[-1, ], drop = F) 
colnames(z) <- "sim_dir"
z <- z %>%
  mutate(simx = str_replace(z$sim_dir,"//","/")) %>%
  select(-sim_dir) %>%
  mutate(sim_dir = paste0(simx,"/","Pred_E",".csv")) %>%
  select(-simx)
  
# write same csv file to all simulation sub-folders
Map(file.copy,
    from = pe_dir,
    to = z$sim_dir,
    overwrite = T)
## $`other/FB4.1_2015_2016/inputs/Main_Inputs/Pred_E.csv`
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE


# coho - Prey_E.csv export

# get master copy file directory for indigestible prey
pred_dir <- paste0(static_inputs_dir,"Prey_E.csv")

# Get list of folders in directory destination
z <- as.data.frame(list.dirs(path = coho_dir)) 
z <- as.data.frame(z[-1, ], drop = F) 
colnames(z) <- "sim_dir"
z <- z %>%
  mutate(simx = str_replace(z$sim_dir,"//","/")) %>%
  select(-sim_dir) %>%
  mutate(sim_dir = paste0(simx,"/","Prey_E",".csv")) %>%
  select(-simx)
  
# write same csv file to all simulation sub-folders
Map(file.copy,
    from = pred_dir,
    to = z$sim_dir,
    overwrite = T)
## $`other/FB4.1_2015_2016/inputs/Main_Inputs/Prey_E.csv`
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE
## 
## $<NA>
## [1] TRUE


Next, we will prepare the “Initial Settings” file for the Fishbioenergetics multi-simulation run, with unique start/end weights for multiple simulations. We will fit simulations to final weight.

Show/Hide Code used to prepare the Initial Settings file


sim_size_inputs_FB4.1 <- read_excel("other/inputs/diet_size_other/sim_size_inputs_v2.xlsx",sheet = "lw_data") %>%
  # create a "species column"
  separate(sim,into = c("year","season","site","spp","foo","age"),sep="\\_",remove = F) %>%
  select(-one_of("year","site","age","season","foo")) %>%
  rename(Simulation = sim,
         # using mean backcalculated weight values by spp/age/sample.event
         Init_W = wt_start) %>%
  mutate(fit.to = "Weight",
         # This input set is formatted to use final lm weight as fitting values
         fitting_value = wt_end,   
         Sp_label = "salmon (adult)",
         Sp = paste(spp,Sp_label),
         First_day = 1,
         Last_day = sim.end.doy - sim.start.doy,
         Ind = 1,
         Oxycal = 13560,
         calc.nut = "FALSE",
         calc.contaminant = "FALSE",
         X_Pred = "NA",
         CONTEQ = 1,
         calc.pop_mort = "FALSE",
         calc.spawn = "FALSE") %>%
  # species abbreviations for folder names
  mutate(spp2 = ifelse(spp == "Chinook", "chnk", ifelse(spp == "Coho", "coho",spp))) %>%
  # create file path for input folders
  mutate(input_folder = paste0("inputs/",spp2,"/",Simulation)) %>%
  # select final column names for input file
  select(Simulation, Sp, input_folder,  
         fit.to,    Init_W, fitting_value ,
         First_day, Last_day, Ind, Oxycal,
         calc.nut, calc.contaminant, X_Pred, 
         CONTEQ, calc.pop_mort, calc.spawn)

## save input csv to local directory
# name directory location
input_csv_dir <- "other/FB4.1_2015_2016/sim_size_inputs_FB4.1.csv"

# remove any previous output versions
file.remove(input_csv_dir)
## [1] TRUE

# write new csv file
write.csv(sim_size_inputs_FB4.1, input_csv_dir, row.names = T)


We now have a csv for simulation size inputs stored in the project GitHub repository at “other/outputs/simulations/sim_size_inputs_FB4.1.csv”, and a folder directory containing 5 csv files for each individual simulation is stored at “other/outputs/simulations/”.

Access these simulation input files here.