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

Add new functions to calculate expanded composition data and input sample sizes #145

Open
wants to merge 63 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
244c046
add fxn to expand length or age composition data
chantelwetzel-noaa Aug 19, 2024
a35a96a
new function to get species name and information
chantelwetzel-noaa Aug 19, 2024
b433f62
New function to calculate input sample size
chantelwetzel-noaa Aug 19, 2024
6d4e5da
add functionality to calculate alt sample sizes
chantelwetzel-noaa Aug 19, 2024
953baaf
add new input sample size column name
chantelwetzel-noaa Aug 19, 2024
058eb71
fix param descriptions
chantelwetzel-noaa Aug 19, 2024
690e167
documentation
chantelwetzel-noaa Aug 19, 2024
7996360
revise function name for clarity
chantelwetzel-noaa Aug 19, 2024
d2569ae
fix tests to use the new input_n column name
chantelwetzel-noaa Aug 19, 2024
4a329a7
complete for missing combinations
chantelwetzel-noaa Aug 23, 2024
80352ae
add deprecation warning
chantelwetzel-noaa Aug 23, 2024
4831436
add tests
chantelwetzel-noaa Aug 23, 2024
0947eef
update vignette
chantelwetzel-noaa Aug 23, 2024
2838578
fix tests
chantelwetzel-noaa Aug 23, 2024
35b5846
Merge remote-tracking branch 'origin/main' into exp_comps
chantelwetzel-noaa Aug 23, 2024
76f2337
add soft deprecation warning
chantelwetzel-noaa Aug 26, 2024
bfab946
refactor to use cli for messages
chantelwetzel-noaa Aug 29, 2024
83d31b9
refactor to cli for messages, fix output for species not in fn
chantelwetzel-noaa Aug 29, 2024
99564b0
add cli package to imports
chantelwetzel-noaa Aug 29, 2024
73ec152
fix check for NAs for strata
chantelwetzel-noaa Aug 29, 2024
af66aa2
add pkg imports
chantelwetzel-noaa Aug 29, 2024
10d2aa4
refactor to testthat::expect_message
chantelwetzel-noaa Aug 29, 2024
e9471f5
document
chantelwetzel-noaa Aug 29, 2024
79c72da
add check for all required column names
chantelwetzel-noaa Aug 30, 2024
43f54a5
refactor: use dplyr::case_when
chantelwetzel-noaa Aug 30, 2024
728de08
add check for sex
chantelwetzel-noaa Aug 30, 2024
7002bca
refactor: add complete to previous dplyr pipe
chantelwetzel-noaa Aug 30, 2024
7f82871
refactor: revised output column names for clarity
chantelwetzel-noaa Aug 30, 2024
44a21a2
refactor: remove duplicate code, rbind the data frame with sex_grouped
chantelwetzel-noaa Aug 30, 2024
2c4b8f3
refactor: switch to dplyr::if_else
chantelwetzel-noaa Aug 30, 2024
ef8d302
refactor: add match.arg check
chantelwetzel-noaa Aug 30, 2024
f53dc8c
add match.arg and revise param name
chantelwetzel-noaa Aug 30, 2024
a817b86
refactor: fix param spacing
chantelwetzel-noaa Aug 30, 2024
f540620
document
chantelwetzel-noaa Aug 30, 2024
627f0ca
remove match.arg due to errors
chantelwetzel-noaa Aug 30, 2024
990988f
update documentation and test
chantelwetzel-noaa Aug 30, 2024
fb840df
add rlang:arg_match0 to check inputs
chantelwetzel-noaa Sep 3, 2024
75b61f6
document and add test
chantelwetzel-noaa Sep 3, 2024
0dcb0b6
add @return description
chantelwetzel-noaa Sep 9, 2024
32610d0
fix param descriptions based on KFJ comments
chantelwetzel-noaa Sep 9, 2024
2d3709b
fix match_arg0
chantelwetzel-noaa Sep 9, 2024
5168c00
refactor fxn input and description
chantelwetzel-noaa Sep 9, 2024
724c58b
add check for required columns
chantelwetzel-noaa Sep 9, 2024
602dc90
add example
chantelwetzel-noaa Sep 11, 2024
ea0bcc1
add required column check
chantelwetzel-noaa Sep 11, 2024
eaa57a4
add strata column check
chantelwetzel-noaa Sep 11, 2024
ae13f30
simplify the bin check and messageing
chantelwetzel-noaa Sep 11, 2024
668fa77
refactor: condense and reorg the processing
chantelwetzel-noaa Sep 11, 2024
27b9e9e
refactor: create labeled dataframe and metadata
chantelwetzel-noaa Sep 11, 2024
4f69c8b
refactor: remove unused calculation
chantelwetzel-noaa Sep 11, 2024
d4272b8
fix arg_match
chantelwetzel-noaa Sep 11, 2024
c0033bd
document
chantelwetzel-noaa Sep 11, 2024
affe116
fix filter
chantelwetzel-noaa Sep 11, 2024
2f11829
add tests
chantelwetzel-noaa Sep 11, 2024
6df575d
refactor: revise function reference in description
chantelwetzel-noaa Sep 17, 2024
149496d
refactor: add ability for plural messaging
chantelwetzel-noaa Sep 17, 2024
0c5548a
refactor: add inform statement for sample size method and species group
chantelwetzel-noaa Sep 20, 2024
0745021
refactor: message for the number of bio samples removed given strata
chantelwetzel-noaa Sep 20, 2024
9293f54
document
chantelwetzel-noaa Sep 23, 2024
4f206f8
refactor: revise default comp_column_name
chantelwetzel-noaa Sep 23, 2024
9fe7c68
refactor: add info about case
chantelwetzel-noaa Sep 23, 2024
af5c934
delete file
chantelwetzel-noaa Sep 23, 2024
46ca556
document
chantelwetzel-noaa Sep 23, 2024
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
3 changes: 3 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Depends:
R (>= 4.0)
Imports:
chron,
cli,
cowplot,
ggmosaic (>= 0.3.4),
ggnewscale,
Expand All @@ -24,7 +25,9 @@ Imports:
httr,
janitor,
jsonlite,
labelled,
lifecycle,
plyr,
purrr,
reshape2,
rlang,
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ export(est_growth)
export(estimate_weight_length)
export(fit_vbgrowth)
export(get_design_based)
export(get_expanded_comps)
export(get_input_n)
export(get_json)
export(get_raw_comps)
export(get_species_info)
export(get_url)
export(label_tow_expansion)
export(plot_age_length_sampling)
export(plot_bio_patterns)
export(plot_comps)
Expand Down
8 changes: 8 additions & 0 deletions R/GetN.fn.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ GetN.fn <- function(
printfolder = "forSS3",
output = NULL,
verbose = TRUE) {
lifecycle::deprecate_soft(
when = "2.5",
what = "nwfscSurvey::GetN.fn()",
details = "The get_expanded_comps() will now do this calculation if specified
in the function input via input_sample_size_method. get_expanded_comps() calls
internally a new function called get_input_n() to determine the input sample
size."
)
species <- match.arg(species)
type <- match.arg(type)
n.unq <- NA
Expand Down
7 changes: 7 additions & 0 deletions R/GetSpp.fn.R
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would hard deprecate this function because the user input is the same as the new function and instead of making an entire new file, I would use git mv R/GetSpp.fn.R R/get_species_info.R so the history of the file is transferred, otherwise as a reviewer it makes me think that all of the code in R/get_species_info.R is new and if it is the exact same I have to do my own diff to see if any of the code has changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is fine with me. Would I do that git command before or after deleting the old file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chantelwetzel-noaa, in case it helps, here's my messy, non-command-line approach which has worked for me in the past using the VS Code git interface. I don't know the best way to undo the commits you've made, but if you're going to squash the commits when you merge it doesn't matter.

  1. In Windows explorer, move the new R/get_species_info.R file out of the repo to git thinks you've deleted it
  2. commit the deletion of the new version
  3. either use the command from @kellijohnson-NOAA above or just rename the file in windows explorer. If you do it in explorer, it will initially appear as having deleted R/GetSpp.fn.R and added R/get_species_info.R, but once you stage the changes it will be shown as a rename
  4. commit the file rename
  5. replace the contents of the file with the backup version of your new R/get_species_info.R that you moved out of the folder, and commit those changes
  6. I don't know if you can create a new version of R/GetSpp.fn.R which only contained a message about hard deprecation without messing up the appearance of the file having been renamed. You could definitely do that after merging this pull request.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
#' )
#'
GetSpp.fn <- function(species, unident = FALSE) {

lifecycle::deprecate_soft(
when = "2.5",
what = "nwfscSurvey::GetSpp.n()",
details = "Please switch to get_species_info()."
)

# background information
sppnames <- nwfscSurvey::PullSpp.fn()
if (!unident) {
Expand Down
5 changes: 5 additions & 0 deletions R/SurveyAFs.fn.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ SurveyAFs.fn <- function(
remove999 = TRUE,
outputStage1 = FALSE,
verbose = TRUE) {
lifecycle::deprecate_soft(
when = "2.5",
what = "nwfscSurvey::SurveyAFs.fn()",
details = "Please switch to get_expanded_comps()."
)
# Overwrite inputs to use the same code for lengths as ages
datL <- datA
lgthBins <- ageBins
Expand Down
6 changes: 6 additions & 0 deletions R/SurveyLFs.fn.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ SurveyLFs.fn <- function(
outputStage1 = FALSE,
sum100 = TRUE,
verbose = TRUE) {
lifecycle::deprecate_soft(
when = "2.5",
what = "nwfscSurvey::SurveyLFs.fn()",
details = "Please switch to get_expanded_comps()."
)

# Check for the number of tows were fish were observed but not measured
postows <- datTows[which(datTows$total_catch_numbers > 0), ]
find <- !(postows$Trawl_id %in% datL$Trawl_id)
Expand Down
Loading
Loading