Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release for v1.0 #103

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/create_tables_doc.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ create_tables_doc <- function(resdir = NULL,
add_chunk(
paste0("rda_dir <- '", rda_dir, "/rda_files'"),
label = "set-rda-dir-tbls",
eval = "false"
eval = "true"
),
"\n"
)
Expand All @@ -51,7 +51,7 @@ rm(rda)\n
indices_table <- indices_table_rda$table
indices_cap <- indices_table_rda$cap"),
label = "tbl-indices-setup",
eval = "true"
eval = "false"
),
"\n"
)
Expand Down
104 changes: 59 additions & 45 deletions R/create_template.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@
#' using the image included in the project's repository.
#' @param bib_file File path to a .bib file used for citing references in
#' the report
#' @param rda_dir The location of the folder containing .rda files
#' ("rda_files") already made with `satf`, or, if the user has not used
#' `satf` to make those .rda files already, rda_dir represents the location
#' that will contain .rda files in an "rda_files" folder. The folder would have
#' been made with `satf::exp_all_figs_tables()`, or by exporting files
#' by running individual `satf` figure- and table-generating functions.
#' If you have used `satf` to generate these .rda files, you can leave
#' the arguments below blank.
#' @param rda_dir If the user has already created .rda files containing
#' figures, tables, alt text, and captions with `satf`, rda_dir represents
#' the location of the folder containing these .rda files ("rda_files").
#' Otherwise, if the user has not used `satf` to make those .rda files already,
#' those files will be generated automatically and placed within the "report"
#' folder within the `file_dir`. The "rda_files" folder would have been
#' made with `satf::exp_all_figs_tables()`, or by exporting files by running individual
#' `satf` figure- and table-generating functions. If you have used `satf` to
#' generate these .rda files, you can leave the arguments below blank. NOTE:
#' If an "rda_files" folder is detected within rda_dir, .rda files will not be
#' regenerated.
#' @param end_year The last year of assessment. The default is year - 1.
#' @inheritParams satf::plot_recruitment
#' @param make_rda This argument is automatically assessed based on the presence
#' or absence of .rda files and should be left blank. TRUE/FALSE; indicate
#' whether to produce an .rda file containing a list with the figure/table,
#' caption, and alternative text (if figure) for each figure and table.
#' @param ref_line An argument inherited from `satf::plot_spawning_biomass.R`.
#' A string specifying the type of reference you want to
#' compare spawning biomass to. The default is `"target"`, which looks for
Expand Down Expand Up @@ -146,6 +146,7 @@
#' create_template(
#' new_section = "a_new_section",
#' section_location = "before-introduction",
#' rda_dir = here::here()
#' )
#'
#'
Expand All @@ -163,6 +164,7 @@
#' model = "SS3",
#' new_section = "an_additional_section",
#' section_location = "after-introduction",
#' rda_dir = here::here()
#' )
#'
#' asar::create_template(
Expand All @@ -177,7 +179,8 @@
#' new_section = c("a_new_section", "another_new_section"),
#' section_location = c("before-introduction", "after-introduction"),
#' custom = TRUE,
#' custom_sections = c("executive_summary", "introduction")
#' custom_sections = c("executive_summary", "introduction"),
#' rda_dir = here::here()
#' )
#'
#' create_template(
Expand Down Expand Up @@ -216,14 +219,13 @@
#' rda_dir = "C:/Users/Documents",
#' unit_label = "metric tons",
#' scale_amount = 1,
#' end_year = NULL,
#' end_year = 2022,
#' n_projected_years = 10,
#' relative = FALSE,
#' make_rda = FALSE,
#' ref_line = c("target", "MSY", "msy", "unfished"),
#' ref_line = "target",
#' spawning_biomass_label = "metric tons",
#' recruitment_label = "metric tons",
#' ref_line_sb = c("target", "MSY", "msy", "unfished")
#' ref_line_sb = "target"
#' )
#' }
#'
Expand Down Expand Up @@ -262,13 +264,12 @@ create_template <- function(
add_image = FALSE,
spp_image = NULL,
bib_file = "asar_references.bib",
rda_dir = NULL,
rda_dir = getwd(),
unit_label = "metric tons",
scale_amount = 1,
end_year = NULL,
n_projected_years = 10,
relative = FALSE,
make_rda = FALSE,
ref_line = c("target", "MSY", "msy", "unfished"),
spawning_biomass_label = "metric tons",
recruitment_label = "metric tons",
Expand All @@ -279,6 +280,11 @@ create_template <- function(
year <- format(as.POSIXct(Sys.Date(), format = "%YYYY-%mm-%dd"), "%Y")
}

# If analyst forgets to add end year, default will be year - 1
if (is.null(end_year)) {
end_year <- as.numeric(year) - 1
}

# Name report
if (!is.null(type)) {
report_name <- paste0(
Expand Down Expand Up @@ -420,22 +426,25 @@ create_template <- function(
# Create tables qmd
if (include_tables) {
if (!is.null(resdir) | !is.null(model_results) | !is.null(model)) {
if (!is.null(rda_dir) & !is.null(end_year)){
# if there is an existing folder with "rda_files" in the rda_dir:
if(dir.exists(fs::path(rda_dir, "rda_files"))){
create_tables_doc(
resdir = resdir,
model_results = model_results,
model = model,
subdir = subdir,
rda_dir = rda_dir
)

} else {
tables_doc <- paste0(
"### Tables \n \n",
"Please refer to the `satf` package downloaded from remotes::install_github('nmfs-ost/satf') to add premade tables."
)
utils::capture.output(cat(tables_doc), file = fs::path(subdir, "08_tables.qmd"), append = FALSE)
warning("Rda directory and/or arguments needed to create .rda files not defined.")
# if there isn't an existing folder with "rda_files" in the rda_dir,
# and the rda_files will be placed in the subdir:
} else {
create_tables_doc(
resdir = resdir,
model_results = model_results,
model = model,
subdir = subdir,
rda_dir = subdir
)
}
} else {
tables_doc <- paste0(
Expand All @@ -457,7 +466,8 @@ create_template <- function(
# Create figures qmd
if (include_figures) {
if (!is.null(resdir) | !is.null(model_results) | !is.null(model)) {
if (!is.null(rda_dir) & !is.null(end_year)){
# if there is an existing folder with "rda_files" in the rda_dir:
if(dir.exists(fs::path(rda_dir, "rda_files"))){
create_figures_doc(
resdir = resdir,
model_results = model_results,
Expand All @@ -466,15 +476,19 @@ create_template <- function(
year = year,
rda_dir = rda_dir
)
} else {
figures_doc <- paste0(
"### Figures \n \n",
"Please refer to the `satf` package downloaded from remotes::install_github('nmfs-ost/satf') to add premade figures."
)
utils::capture.output(cat(figures_doc), file = fs::path(subdir, "09_figures.qmd"), append = FALSE)
warning("Rda directory and/or arguments needed to create .rda files not defined.")
}
} else {
# if there isn't an existing folder with "rda_files" in the rda_dir,
# and the rda_files will be placed in the subdir:
} else {
create_figures_doc(
resdir = resdir,
model_results = model_results,
model = model,
subdir = subdir,
year = year,
rda_dir = subdir
)
}
} else {
figures_doc <- paste0(
"### Figures \n \n",
"Please refer to the `satf` package downloaded from remotes::install_github('nmfs-ost/satf') to add premade figures."
Expand Down Expand Up @@ -769,9 +783,9 @@ create_template <- function(
}

# run satf::exp_all_figs_tables() if rda files not premade
if (!is.null(rda_dir) & !is.null(end_year)){

if(!dir.exists(file.path(rda_dir, "rda_files"))){
# output folder: subdir
if(!dir.exists(fs::path(rda_dir, "rda_files"))){
if (!is.null(resdir) | !is.null(model_results)) {

# load converted output
output <- utils::read.csv(paste0(resdir, "/", model_results))
Expand All @@ -785,14 +799,14 @@ create_template <- function(
n_projected_years = n_projected_years,
relative = relative,
make_rda = TRUE,
rda_dir = rda_dir,
rda_dir = subdir,
ref_line = ref_line,
spawning_biomass_label = spawning_biomass_label,
recruitment_label = recruitment_label,
ref_line_sb = ref_line_sb
)
)
}
}
}


# print("_______Standardized output data________")
Expand Down Expand Up @@ -821,7 +835,7 @@ create_template <- function(
" ", "dplyr::summarize(max_val = max(year)) |> \n",
" ", "dplyr::pull(max_val))-10", "\n",
# for quantities - don't want any values that are split by factor
"# subset output to remove quantities that are fplit by factor \n",
"# subset output to remove quantities that are split by factor \n",
"output2 <- output |> \n",
" ", "dplyr::filter(is.na(season), \n",
" ", " ", "is.na(fleet), \n",
Expand Down
28 changes: 18 additions & 10 deletions inst/resources/affiliation_info.csv
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
affiliation,office,name,address,city,state,country,postal-code
OST-MD,OST,Office of Science and Technology,1315 East-West Highway,Silver Spring,MD,U.S.A.,20910
AFSC-NOR,AFSC,Alaska Fisheries Science Center,2032 SE OSU Drive Building 955,Newport,OR,U.S.A.,97365-2097
AFSC-SWA,AFSC,Alaska Fisheries Science Center,2725 Montlake Boulevard East,Seattle,WA,U.S.A.,98112-2097
AFSC-JAK,AFSC,Alaska Fisheries Science Center,17109 Point Lena Loop Road,Juneau,AK,U.S.A.,99801
AFSC,AFSC,Alaska Fisheries Science Center,17109 Point Lena Loop Road,Juneau,AK,U.S.A.,99801
AFSC-WA,AFSC,Alaska Fisheries Science Center,7600 Sand Point Way N.E.,Seattle,WA,U.S.A.,98115
AFSC-ABL,AFSC,Alaska Fisheries Science Center,17109 Point Lena Loop Road,Juneau,AK,U.S.A.,99801
CDFW,CDFW,California Department of Fish and Wildlife,"1123 Industrial Rd., Suite 300",San Carlos,CA,U.S.A.,94070
NEFSC,NEFSC,Northeast Fisheries Science Center,166 Water Street,Woods Hole,MA,U.S.A.,2543
NEFSC-WHMA,NEFSC,Northeast Fisheries Science Center,166 Water Street,Woods Hole,MA,U.S.A.,2543
NEFSC-NRI,NEFSC,Northeast Fisheries Science Center,28 Tarzwell Drive,Narragansett,RI,U.S.A.,2882
NEFSC-MCT,NEFSC,Northeast Fisheries Science Center,212 Rogers Avenue,Milford,CT,U.S.A.,6460
NWFSC,NWFSC,Northwest Fisheries Science Center,2725 Montlake Boulevard East,Seattle,WA,U.S.A.,98112-2097
NWFSC-NOR,NWFSC,Northwest Fisheries Science Center,2032 SE OSU Drive Building 955,Newport,OR,U.S.A.,97365-2097
NWFSC-SWA,NWFSC,Northwest Fisheries Science Center,2725 Montlake Boulevard East,Seattle,WA,U.S.A.,98112-2097
ODFW,ODFW,Oregon Department of Fish and Wildlife,2040 Southeast Marine Science Drive,Newport,OR,U.S.A.,97365
OST-MD,OST,Office of Science and Technology,1315 East-West Highway,Silver Spring,MD,U.S.A.,20910
PIFSC,PIFSC,Pacific Islands Fisheries Science Center,1845 Wasp Boulevard,Honolulu,HI,U.S.A.,96818
PSMFC,NWFSC,Pacific States Marine Fisheries Commission,2725 Montlake Boulevard East,Seattle,WA,U.S.A.,98112-2097
SEFSC,SEFSC,Southeast Fisheries Science Center,75 Virginia Beach Drive,Miami,FL,U.S.A.,33149
SEFSC-MFL,SEFSC,Southeast Fisheries Science Center,75 Virginia Beach Drive,Miami,FL,U.S.A.,33149
SEFSC-BNC,SEFSC,Southeast Fisheries Science Center,101 Pivers Island Road,Beaufort,NC,U.S.A.,28516
SEFSC-PCFL,SEFSC,Southeast Fisheries Science Center,3500 Delwood Beach Road,Panama City,FL,U.S.A.,32408
SEFSC-GTX,SEFSC,Southeast Fisheries Science Center,4700 Avenue U,Galveston,TX,U.S.A.,77551
SEFSC-PMS,SEFSC,Southeast Fisheries Science Center,3209 Frederic Street,Pascagoula,MS,U.S.A.,39567
SEFSC-LLA,SEFSC,Southeast Fisheries Science Center,646 Cajundome Boulevard,Lafayette,LA,U.S.A.,70506
NWFSC,NWFSC,Northwest Fisheries Science Center,2725 Montlake Boulevard East,Seattle,WA,U.S.A.,98112-2097
NWFSC-NOR,NWFSC,Northwest Fisheries Science Center,2032 SE OSU Drive Building 955,Newport,OR,U.S.A.,97365-2097
NWFSC-SWA,NWFSC,Northwest Fisheries Science Center,2725 Montlake Boulevard East,Seattle,WA,U.S.A.,98112-2097
SWFSC-LJCA,SWFSC,Southwest Fisheries Science Center,8901 La Jolla Shores Drive,La Jolla,CA,U.S.A.,92037
AFSC-NOR,AFSC,Alaska Fisheries Science Center,2032 SE OSU Drive Building 955,Newport,OR,U.S.A.,97365-2097
AFSC-SWA,AFSC,Alaska Fisheries Science Center,2725 Montlake Boulevard East,Seattle,WA,U.S.A.,98112-2097
AFSC-JAK,AFSC,Alaska Fisheries Science Center,17109 Point Lena Loop Road,Juneau,AK,U.S.A.,99801
AFSC,AFSC,Alaska Fisheries Science Center,17109 Point Lena Loop Road,Juneau,AK,U.S.A.,99801
PIFSC,PIFSC,Pacific Islands Fisheries Science Center,1845 Wasp Boulevard,Honolulu,HI,U.S.A.,96818
AFSC-ABL,AFSC,Alaska Fisheries Science Center,17109 Point Lena Loop Road,Juneau,AK,U.S.A.,99801
SWFSC-SC,SWFSC,Southwest Fisheries Science Center,110 McAllister Way,Santa Cruz,CA,U.S.A.,95060
UAF,UAF,University of Alaska Fairbanks,"Department of Fisheries at Lena Point, College of Fisheries and Ocean Sciences, University of Alaska Fairbanks, 17101 Point Lena Loop Rd",Juneau,AK,U.S.A.,99801
WCR,WCR,West Coast Region,7600 Sand Point Way N.E.,Seattle,WA,U.S.A.,98115
WDFW,WDFW,Washington Department of Fish and Wildlife,600 Capital Way North,Olympia,WA,U.S.A.,98501
40 changes: 31 additions & 9 deletions inst/resources/authorship.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,99 @@ last,first,mi,office
Adams,Charles,,NEFSC
Ailloud,Lisa,,SEFSC
Allen Akselrud,Caitlin,,SWFSC-LJCA
Berger,Aaron,M.,NWFSC-SWA
Berger,Aaron,M.,NWFSC-NOR
Beyer,Sabrina,,NWFSC-SWA
Bizzarro,Joseph,J.,SWFSC-SC
Blackhart,Kristan,,NEFSC
Boucher,Jason,,NEFSC
Brodziak,John,,PIFSC
Brown,Russell,W.,NEFSC-WHMA
Budrick,John,E.,CDFW
Carvalho,Felipe,,PIFSC
Chang,Jui-Han,,NEFSC
Chute,Toni,,NEFSC
Coates,Julia,,CDFW
Cope,Jason,M.,NWFSC-SWA
Correa,Giancarlo,M.,AFSC
Curti,Kiersten,,NEFSC
Damiano,Matt,,SEFSC
Deary,Alison,L.,AFSC
Deroba,Jon,,NEFSC
Dick,E.,J.,SWFSC-SC
Dorn,Martin,W.,AFSC
Ducharme-Barth,Nicholas,,PIFSC
Dunn,Alex,,NEFSC
Feddern,Megan,L.,NWFSC-SWA
Ferriss,Bridget,E.,AFSC
Field,John,,SWFSC
Field,John,,SWFSC-SC
Fitchett,Mark,D.,PIFSC
Forrestal,Francesca,,SEFSC-MFL
Gertseva,Vladlena,,NWFSC
Haltuch,Melissa,A.,AFSC-SWA
Gertseva,Vladlena,,NWFSC-SWA
Haltuch,Melissa,A.,AFSC-WA
Hamel,Owen,S.,NWFSC-SWA
Hart,Dvora,,NEFSC
Hastie,Jim,,NWFSC-SWA
Havron,Andrea,,OST
Head,Melissa,A.,NWFSC-SWA
Hendrickson,Lisa,,NEFSC
Hennen,Dan,,NEFSC
Hernvann,Pierre-Yves,,NWFSC-SWA
Hill,Kevin,T.,SWFSC-LJCA
Hillier,Lisa,K.,WDFW
Hinton,Kristen,E.,WDFW
Johnson,Kelli,F.,NWFSC-SWA
Jones,Andy,,NEFSC
Kapur,Maia,R.,PIFSC
Kapur,Maia,S.,AFSC-WA
Kuriyama,Peter,T.,SWFSC-LJCA
Lam,Laurel,S.,PSMFC
Langseth,Brian,J.,NWFSC-SWA
Legault,Chris,,NEFSC
Levine,Mike,,AFSC
Marshall,Kristan,,NWFSC
Marshall,Kristan,,NWFSC-SWA
Matson,Sean,E.,WCR
McGowan,David,W.,AFSC
Methot,Richard,,NWFSC
Monk,Melissa,,SWFSC
Monk,Melissa,,SWFSC-SC
Monnahan,Cole,C.,AFSC
Nieland,Julie,,NEFSC
Niles,Corey,B.,WDFW
Nitschke,Paul,,NEFSC
O'Keefe,Cate,,NEFSC
Oken,Kiva,L.,NWFSC-SWA
Oshima,Megumi,,PIFSC
Perretti,Charles,,NEFSC
Rios,Adyan,,SEFSC
Rogers,Lauren,,AFSC
Rogers,Tanya,L.,SWFSC-SC
Saas,Emma,M.,SWFSC-SC
Sagarese,Skyler,,SEFSC-MFL
Sculley,Michelle,,PIFSC
Shank,Burton,,NEFSC
Shertzer,Kyle,,SEFSC-BNC
Shotwell,S.,Kalei,AFSC
Siegfried,Katie,,SEFSC
Sosebee,Karson,,NEFSC
Spies,Ingrid,,AFSC-WA
Stawitz,Christine,,OST
Sullivan,Jane,,AFSC
Sullivan,Jane,Y.,AFSC
Syslo,John,,PIFSC
Taylor,Ian,G.,NWFSC-SWA
Tolimieri,Nick,,NWFSC-SWA
Traver,Michele,,NEFSC
Tsou,Tien-Shui,,WDFW
Tyrell,Abigail,,NEFSC
Wassermann,Sophia,N.,AFSC-SWA
Veron,Matthieu,,AFSC-WA
Wallace,John,R.,NWFSC-SWA
Wassermann,Sophia,N.,AFSC-WA
Wetzel,Chantel,R.,NWFSC-SWA
Whitman,Alison,D.,ODFW
Wigley,Susan,,NEFSC
Williams,Ben,,AFSC
Williams,Erik,,SEFSC
Wood,Anthony,,NEFSC
Yau,Annie,J.,PIFSC
Zador,Stephani,,AFSC
Zahner,Joshua,A.,UAF
Zwolinski,Juan,P.,SWFSC-LJCA
Snow,John,,AFSC
Phantom,Danny,,NEFSC
Expand Down
Loading
Loading