Skip to content

Commit

Permalink
refactor (*.R): Adhere to tidyverse principals
Browse files Browse the repository at this point in the history
by cleaning up the R code

Removes functions
* mkObj
* create_rcpp_interface_object
* use_module
* %>%
* FIMSFrameAge

Adds importFrom(TMB, MakeADFun) to package b/c TMB is no longer
explicitly used in the codebase. And, experimented with removing usethis
b/c it was also used in ./R/ but is still used in data-raw. It is now a
suggested package. Uses :: instead of importing functions, e.g.,
utils::head().

* Constricts line width to 80 characters
* Use full stops at the end of sentences
* Implement more spacing in between roxygen tags
* Move export tag to the end in most instances
* Use explicit brackets for if statements
* Remove duplicated code in gtest by calling run_gtest()
* Parameter and object names to snake_case
* Parameter, function, and object names, largely, w/o abbreviations

fix(run_gtest): Use paste() instead of paste0() to ensure proper spacing
which is not explicit in the instructions. With paste()
they can input as many additional arguments as they want and they are
all automatically separated, e.g.,
`run_gtest("--something", "--something-else")`

Close #588
Close #564
Close #590
  • Loading branch information
MOshima-PIFSC authored and kellijohnson-NOAA committed May 14, 2024
1 parent fe5836b commit 2431f59
Show file tree
Hide file tree
Showing 35 changed files with 245 additions and 814 deletions.
7 changes: 3 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,17 @@ Imports:
dplyr,
ggplot2,
jsonlite,
magrittr,
methods,
Rcpp,
scales,
TMB (>= 1.8.0),
usethis
TMB (>= 1.8.0)
Suggests:
covr,
knitr,
remotes,
rmarkdown,
testthat (>= 3.0.0)
testthat (>= 3.0.0),
usethis
LinkingTo:
Rcpp,
RcppEigen,
Expand Down
9 changes: 0 additions & 9 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(AgeComp)
export(BevertonHoltRecruitment)
export(CreateTMBModel)
export(DoubleLogisticSelectivity)
export(EWAAgrowth)
export(FIMSFrame)
export(FIMSFrameAge)
export(Fleet)
export(Index)
export(LogisticMaturity)
Expand All @@ -19,17 +17,14 @@ export(TMBDmultinomDistribution)
export(TMBDnormDistribution)
export(clear)
export(clear_logs)
export(create_fims_rcpp_interface)
export(get_fixed)
export(get_random)
export(m_agecomp)
export(m_index)
export(m_landings)
export(mkObj)
export(run_gtest)
export(setup_and_run_gtest)
export(setup_gtest)
export(use_module)
exportMethods(m_agecomp)
exportMethods(m_index)
exportMethods(m_landings)
Expand All @@ -38,8 +33,4 @@ import(stats)
importFrom(Rcpp,sourceCpp)
importFrom(TMB,MakeADFun)
importFrom(ggplot2,.data)
importFrom(magrittr,"%>%")
importFrom(usethis,ui_stop)
importFrom(usethis,use_template)
importFrom(utils,head)
useDynLib(FIMS, .registration = TRUE)
3 changes: 1 addition & 2 deletions R/FIMS-package.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
## usethis namespace: start
#' @useDynLib FIMS, .registration = TRUE
#' @importFrom Rcpp sourceCpp
#' @importFrom utils head
#' @importFrom TMB MakeADFun
#' @import stats
#' @import methods
#' @importFrom ggplot2 .data
#' @importFrom usethis use_template ui_stop
#' @export CreateTMBModel
#' @export get_fixed
#' @export get_random
Expand Down
175 changes: 0 additions & 175 deletions R/create_rcpp_interface_object.R

This file was deleted.

8 changes: 4 additions & 4 deletions R/data_mile1.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#' {FIMS} input data frame for milestone 1
#' FIMS input data frame for milestone 1
#'
#' A dataset containing information necessary to run an age-structured stock
#' assessment model in {FIMS} for milestone 1. This data was generated using
#' the `ASSAMC` package written for the
#' [model comparison project](www.github.com/Bai-Li-NOAA/Age_Structured_Stock_Assessment_Model_Comparison).
#' assessment model in FIMS for milestone 1. This data was generated using
#' the `ASSAMC` package written for the [model comparison project](
#' www.github.com/Bai-Li-NOAA/Age_Structured_Stock_Assessment_Model_Comparison).
#'
#' @format A data frame with `r NROW(data_mile1)` observations of
#' `r NCOL(data_mile1)` variables:
Expand Down
Loading

0 comments on commit 2431f59

Please sign in to comment.