Skip to content
Open
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
13 changes: 9 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
"features": {
"ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": {},
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
"packages": "make,gcc,g++,cmake,clang-tidy,clang-format"
"packages": "make,gcc,g++,cmake,clang-tidy,clang-format,libuv1-dev"
},
"ghcr.io/rocker-org/devcontainer-features/r-packages:1": {
"packages": "cli,rlang,usethis,devtools,ggplot2,remotes,pak",
"ghcr.io/rocker-org/devcontainer-features/r-packages:1": {
"packages": "cli,rlang,usethis,devtools,ggplot2,gt,remotes,pak",
"cranMirror": "https://cloud.r-project.org",
"installSystemRequirements": true
}
},
Expand Down Expand Up @@ -42,7 +43,11 @@
"requireLocalPort": true,
"onAutoForward": "ignore"
}
},
},
"postCreateCommand": [
"sudo", "-n", "Rscript", "-e",
"write('options(repos = c(CRAN = \"https://cloud.r-project.org\"))', file = file.path(R.home('etc'), 'Rprofile.site'), append = TRUE)"
],
"postAttachCommand": "sudo rstudio-server start",
"remoteUser": "rstudio"

Expand Down
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Imports:
utils
Suggests:
flextable,
ggridges,
here,
kableExtra,
knitr,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ export(extract_sis_data)
export(filter_data)
export(plot_aa)
export(plot_abundance_at_age)
export(plot_age_to_length_conversion)
export(plot_biomass)
export(plot_biomass_at_age)
export(plot_catch_at_age)
export(plot_data_availability)
export(plot_density)
export(plot_discard)
export(plot_fishing_mortality)
export(plot_index)
Expand Down
53 changes: 51 additions & 2 deletions R/conout_ss3.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ conout_ss3 <- function(
rand <- c(
"SPAWN_RECRUIT_CURVE", # RAND
"sprseries", # RAND
"parameters" # RAND
"parameters", # RAND
# "equil_yeild", # SKIP FOR NOW - RAND
"ALK"
# "AAK"
)
aa.al <- c(
"sizeselex", # AA.AL
Expand Down Expand Up @@ -230,7 +232,7 @@ conout_ss3 <- function(
extract <- file[[parm_sel]]
}

if (!is.data.frame(extract)) {
if (!is.data.frame(extract) && parm_sel %notin% c("ALK")) {
if (is.numeric(extract)) {
df <- data.frame(
label = parm_sel,
Expand Down Expand Up @@ -677,6 +679,8 @@ conout_ss3 <- function(
# "SPAWN_RECR_CURVE"
# "Biology_at_age_in_endyr"
# "PARAMETERS"
# "ALK"
# "AAK"

if (parm_sel %in% c("SPAWN_RECR_CURVE", "SPAWN_RECRUIT_CURVE")) {
# 32
Expand Down Expand Up @@ -985,6 +989,51 @@ conout_ss3 <- function(
df4[setdiff(tolower(names(out_new)), tolower(names(df4)))] <- NA
# Add to out list
out_list[[parm_sel]] <- df4
} else if (parm_sel == "ALK") {
# extract matrix into df
# ID dimensions and assign
df1 <- as.data.frame.table(extract, responseName = "value", stringsAsFactors = FALSE)
colnames(df1)[1:3] <- c("len_bins", "age", "slice_label")

# Dynamically extract all "Key: Value" pairs and pivot
df2 <- df1 |>
# Match every 'Word: Number' pair (supporting decimals and negative numbers)
dplyr::mutate(pairs = stringr::str_extract_all(slice_label, "([A-Za-z0-9_]+):\\s*([-+]?\\d*\\.?\\d+)")) |>
tidyr::unnest(pairs) |>
tidyr::separate_wider_delim(
cols = pairs,
delim = ":",
names = c("variable", "val")
) |>
dplyr::mutate(
variable = stringr::str_trim(variable),
val = type.convert(stringr::str_trim(val), as.is = TRUE) # Automatically parses numeric types
) |>
tidyr::pivot_wider(
names_from = variable,
values_from = val
) |>
dplyr::select(-slice_label) |>
dplyr::relocate(len_bins, age, tidyselect::where(is.numeric), value)
colnames(df2) <- tolower(colnames(df2))
# rename columns if not std & add module_name + label
# I believe this is the only ones
rename_map <- c(
season = "seas",
subseason = "sub_seas" ,
estimate = "value"
# gp = "growth_pattern"
)
df3 <- df2 |>
dplyr::rename(dplyr::any_of(rename_map)) |>
dplyr::mutate(
module_name = parm_sel,
label = "age_to_length_conversion")
df3[setdiff(tolower(names(out_new)), tolower(names(df3)))] <- NA
# Add to out list
out_list[[parm_sel]] <- df3
} else if (parm_sel == "AAK") {
miss_parms <- c(miss_parms, parm_sel)
} else {
miss_parms <- c(miss_parms, parm_sel)
next
Expand Down
1 change: 0 additions & 1 deletion R/convert_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ convert_output <- function(
dplyr::rename(length_bins = len_bins)
}


out_new <- out_new |>
dplyr::mutate(
model=model_name,
Expand Down
Loading
Loading