Skip to content

Commit

Permalink
Merge pull request #14 from Bai-Li-NOAA/main
Browse files Browse the repository at this point in the history
Add setup.qmd file to facilitate the management of all required packages in the repository's code
  • Loading branch information
Bai-Li-NOAA authored Feb 16, 2024
2 parents e00bfad + 252a0ac commit 6039372
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 68 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/render-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ jobs:
uses: r-lib/actions/setup-r@v2

- name: Install packages (needed for Rmd)
run: Rscript -e 'install.packages(c("rmarkdown", "knitr", "jsonlite","dplyr","tidyr","ggplot2", "TMB", "remotes"))'

- name: Install TMB helper
run: Rscript -e 'remotes::install_github("kaskr/TMB_contrib_R/TMBhelper")'

- name: Install FIMS
run: Rscript -e 'remotes::install_github("NOAA-FIMS/FIMS")'
run: Rscript -e 'install.packages(c("rmarkdown", "knitr", "jsonlite"))'

- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
Expand Down
4 changes: 2 additions & 2 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ website:
text: Home
- href: content/case-study-template.qmd
text: Case study template
- href: content/SWFSC-sardine.qmd
text: SWFSC sardine case study
- href: content/rendering.qmd
text: Rendering
- href: content/rmarkdown.Rmd
Expand All @@ -47,6 +45,8 @@ website:
text: AFSC GOA pollock case study
- href: content/AFSC-BSAI-AtkaMackerel.qmd
text: AFSC BSAI Atka Mackerel case study
- href: content/SWFSC-sardine.qmd
text: SWFSC sardine case study
- href: content/acknowledgements.qmd
text: Acknowledgements

Expand Down
24 changes: 5 additions & 19 deletions content/AFSC-BSAI-AtkaMackerel.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,21 @@ editor_options:
chunk_output_type: console
---


## The setup

{{< include setup.qmd >}}

```{r}
#| warning: false
#| label: startup
#| output: false
packages <- c("dplyr", "tidyr", "ggplot2", "remotes", "here", "TMB")
# Install packages not yet installed
installed_packages <- packages %in% rownames(installed.packages())
if (any(installed_packages == FALSE)) {
install.packages(packages[!installed_packages], repos = "http://cran.us.r-project.org")
}
# Load packages
invisible(lapply(packages, library, character.only = TRUE))
library(FIMS)
library(TMB)
library(TMBhelper)
## devtools::install_github('afsc-assessments/GOApollock', ref='v0.1.2')
## library(GOApollock)
theme_set(theme_bw())
R_version <- version$version.string
TMB_version <- packageDescription("TMB")$Version
FIMS_commit <- substr(packageDescription("FIMS")$GithubSHA1, 1, 7)
# R_version <- version$version.string
# TMB_version <- packageDescription("TMB")$Version
# FIMS_commit <- substr(packageDescription("FIMS")$GithubSHA1, 1, 7)
```

- R version: `r R_version`\
Expand Down
22 changes: 5 additions & 17 deletions content/AFSC-GOA-pollock.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,19 @@ format:

## The setup

{{< include setup.qmd >}}

```{r}
#| warning: false
#| label: startup
#| output: false
packages <- c("dplyr", "tidyr", "ggplot2", "remotes", "reshape2", "TMB")
# Install packages not yet installed
installed_packages <- packages %in% rownames(installed.packages())
if (any(installed_packages == FALSE)) {
install.packages(packages[!installed_packages], repos = "http://cran.us.r-project.org")
}
# Load packages
invisible(lapply(packages, library, character.only = TRUE))
library(FIMS)
library(TMB)
library(TMBhelper)
theme_set(theme_bw())
R_version <- version$version.string
TMB_version <- packageDescription("TMB")$Version
FIMS_commit <- substr(packageDescription("FIMS")$GithubSHA1, 1, 7)
# R_version <- version$version.string
# TMB_version <- packageDescription("TMB")$Version
# FIMS_commit <- substr(packageDescription("FIMS")$GithubSHA1, 1, 7)
```

- R version: `r R_version`\
Expand Down
24 changes: 6 additions & 18 deletions content/NEFSC-yellowtail.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,15 @@ format:

## The setup

{{< include setup.qmd >}}

```{r}
#| warning: false
#| label: package-installation
# Names of required packages
packages <- c("dplyr", "tidyr", "ggplot2", "remotes", "TMB")
# Install packages not yet installed
installed_packages <- packages %in% rownames(installed.packages())
if (any(installed_packages == FALSE)) {
install.packages(packages[!installed_packages], repos = "http://cran.us.r-project.org")
}
# Load packages
invisible(lapply(packages, library, character.only = TRUE))
library(FIMS)
library(TMB)
library(TMBhelper)
#| label: startup
R_version <- version$version.string
TMB_version <- packageDescription("TMB")$Version
FIMS_commit <- substr(packageDescription("FIMS")$GithubSHA1, 1, 7)
# R_version <- version$version.string
# TMB_version <- packageDescription("TMB")$Version
# FIMS_commit <- substr(packageDescription("FIMS")$GithubSHA1, 1, 7)
```

- R version: `r R_version`\
Expand Down
3 changes: 3 additions & 0 deletions content/case-study-template.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ and start the qmd file with a level header `# `, but if using the default title
## Add a chunk of code describing your setup

Case study files should include:

* R version
* TMB version
* FIMS commit
* Name of your stock
* Name of your region
* Name of the analyst

Please ensure that the [`content/setup.qmd`](https://github.com/NOAA-FIMS/case-studies/blob/main/content/setup.qmd) file is updated if the case study requires the installation of additional R packages.

## Add a bulleted list and script describing simplifications you had to make

How I simplified my assessment
Expand Down
26 changes: 26 additions & 0 deletions content/setup.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
```{r}
#| warning: false
#| label: package-installation
# Names of required packages
packages <- c("dplyr", "tidyr", "ggplot2", "TMB", "reshape2", "here", "remotes")
# Install packages not yet installed
installed_packages <- packages %in% rownames(installed.packages())
if (any(installed_packages == FALSE)) {
install.packages(packages[!installed_packages], repos = "http://cran.us.r-project.org")
}
remotes::install_github("kaskr/TMB_contrib_R/TMBhelper")
remotes::install_github("NOAA-FIMS/FIMS")
# Load packages
invisible(lapply(packages, library, character.only = TRUE))
library(FIMS)
library(TMBhelper)
R_version <- version$version.string
TMB_version <- packageDescription("TMB")$Version
FIMS_commit <- substr(packageDescription("FIMS")$GithubSHA1, 1, 7)
```
5 changes: 0 additions & 5 deletions index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@ page-layout: full
---

These case studies demonstrate use of the Fisheries Integrated Modeling System to run a few different cases of stock assessment models.

```{r, eval = FALSE}
install.packages(c("dplyr","tidyr","ggplot2","TMB","TMBhelper")
remotes::install_github("NOAA-FIMS/FIMS")
```

0 comments on commit 6039372

Please sign in to comment.