icessag
R interface to Stock Assessment Graphs database web services
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.0%) to scientific vocabulary
Last synced: 10 months ago
·
JSON representation
Repository
R interface to Stock Assessment Graphs database web services
Basic Info
- Host: GitHub
- Owner: ices-tools-prod
- Language: R
- Default Branch: main
- Homepage: https://sg.ices.dk/webservices.aspx
- Size: 729 KB
Statistics
- Stars: 12
- Watchers: 7
- Forks: 7
- Open Issues: 85
- Releases: 11
Created almost 10 years ago
· Last pushed about 1 year ago
Metadata Files
Readme
Changelog
README.Rmd
---
output:
md_document:
variant: gfm
---

[](https://ices-tools-prod.r-universe.dev)
[](https://ices-tools-prod.r-universe.dev/icesSAG)
$Version`-blue)
[]()
[-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.en.html)
CRAN status:
[](https://cran.r-project.org/package=icesSAG)


[
](http://ices.dk)
### icesSAG
icesSAG provides R functions that access the
[web services](https://sg.ices.dk/webservices.aspx) of the [ICES](https://www.ices.dk)
[Stock Assessment Graphs](https://sg.ices.dk) database.
icesSAG is implemented as an [R](https://www.r-project.org) package and
is currently hosted on [r-universe](https://ices-tools-prod.r-universe.dev)
and available on [CRAN](https://cran.r-project.org/package=icesSAG).
### Installation
The stable version of icesSAG can be installed from CRAN using the `install.packages` command:
```r
install.packages("icesSAG", repos = "https://cloud.r-project.org")
```
or a potentially more recent, but less stable version installed from r-universe:
```r
install.packages("icesSAG", repos = "https://ices-tools-prod.r-universe.dev")
```
### Usage
For a summary of the package:
```r
library(icesSAG)
?icesSAG
```
### Examples
```{r, echo = FALSE}
options(icesSAG.messages = FALSE)
options(icesSAG.use_token = FALSE)
library(icesSAG)
library(ggplot2)
```
To download the summary data for all sandeel stocks published in 2018 use:
```{r}
summary_data <- getSAG(stock = "sandeel", year = 2023)
head(summary_data)
ggplot(summary_data[complete.cases(summary_data[c("Year", "recruitment")]),],
aes(x=Year, y=recruitment, group = fishstock, colour = fishstock)) +
geom_line()
```
#### verbose web service calls
If you want to see all the web service calls being made set this option
```{r echo = TRUE}
sag_messages(TRUE)
```
The result will be
```{r}
codKeys <- findAssessmentKey("cod", year = 2017)
```
which allows you to investigate the actual web service data if you are interested:
[https://sag.ices.dk/SAG_API/api/StockList?year=2017](https://sag.ices.dk/SAG_API/api/StockList?year=2017)
#### Authorised access via tokens
ICES provides public access to the results of published stock assessments. If you are an ICES stock assessor and wish to access unpublished results, or to upload your results, this can be done using token authentication.
This is easy to set up, simply run the following line and all future requests to the SAG database will be authenticated.
```r
sag_use_token(TRUE)
```
#### uploading data
To upload the results of a stock assessment to SAG you must provide two pieces of information, Stock information, such as stock code, assessment year and reference points, and yearly results, such as landings and estimated fishing mortality. There are two helper functions to create the required objects.
```r
stockInfo()
```
returns a `list` (it requires a stock code, assessment year and contact email as a minimum), with the correctly named elements. And,
```r
stockFishdata()
```
returns a `data.frame` (it requires year as default) with the correctly named columns
A simple (almost) minimal example is:
```{r echo = FALSE}
sag_messages(FALSE)
```
```{r, eval=FALSE}
info <-
stockInfo(
StockCode = "whg.27.7a",
AssessmentYear = 2021,
ContactPerson = "its_me@somewhere.gov",
StockCategory = 3,
Purpose = "Unofficial",
ModelType = "A",
ModelName = "XSA"
)
fishdata <- stockFishdata(1950:2020)
# simulate some landings for something a bit intesting
set.seed(1232)
fishdata$Landings <- 10^6 * exp(cumsum(cumsum(rnorm(nrow(fishdata), 0, 0.1))))
# you can create an XML file to upload yourself
xml <- createSAGxml(info, fishdata)
# here we use a temporary file to store the XML, but you can safe this to your output or report folder
tempfile <- tempfile(fileext = ".xml")
cat(xml, file = tempfile)
# this file can then be uploaded using the SAG webservices
key <- uploadStock(tempfile, upload = TRUE)
# if you want to just check the file and not upload:
uploadStock(tempfile, upload = FALSE)
```
You can check that the data was uploaded by searching for our stock. Note you will need to make sure the icesSAG.use_token option is set to TRUE
```{r}
sag_use_token(TRUE)
findAssessmentKey('whg.27.7a', 2020, full = TRUE)
```
### Displaying graphs
We can also look at the landings graph created from the data that were uploaded, NOTE you may need to modify the settings at sag.ices.dk.
```{r, landings-plot, eval=FALSE}
plot(getLandingsGraph(key))
```
or download all four summary graphs and display them in a 2x2 grid.
```{r, summary-plot, eval=FALSE}
graphs <- getSAGGraphs(key)
plot(graphs)
```
### References
ICES Stock Assessment Graphs database:
https://sg.ices.dk
ICES Stock Assessment Graphs web services:
https://sg.ices.dk/webservices.aspx
### Development
icesSAG is developed openly on
[GitHub](https://github.com/ices-tools-prod/icesSAG).
Feel free to open an [issue](https://github.com/ices-tools-prod/icesSAG/issues)
there if you encounter problems or have suggestions for future versions.
The current development version can be installed using:
```R
library(devtools)
install_github("ices-tools-prod/icesSAG@development")
```
Owner
- Name: ICES tools (production)
- Login: ices-tools-prod
- Kind: organization
- Email: taf@ices.dk
- Location: Copenhagen, Denmark
- Website: https://www.ices.dk/data/tools/Pages/Software.aspx
- Repositories: 34
- Profile: https://github.com/ices-tools-prod
Tools that are operational and maintained by the ICES Secretariat
GitHub Events
Total
- Create event: 4
- Release event: 1
- Issues event: 46
- Watch event: 1
- Delete event: 8
- Member event: 2
- Issue comment event: 55
- Push event: 55
- Pull request review event: 1
- Pull request event: 2
- Fork event: 1
Last Year
- Create event: 4
- Release event: 1
- Issues event: 46
- Watch event: 1
- Delete event: 8
- Member event: 2
- Issue comment event: 55
- Push event: 55
- Pull request review event: 1
- Pull request event: 2
- Fork event: 1
Committers
Last synced: 11 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| colin millar | c****r@g****m | 271 |
| Arni Magnusson | a****a@h****s | 44 |
| slarge | l****i@g****m | 16 |
| Colin Millar | c****n@i****k | 10 |
| Adriana Villamor | a****r@i****l | 7 |
| Luca Lamoni | l****i@g****m | 1 |
| Adriana | v****0@g****m | 1 |
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 134
- Total pull requests: 15
- Average time to close issues: about 1 year
- Average time to close pull requests: 6 months
- Total issue authors: 22
- Total pull request authors: 4
- Average comments per issue: 1.35
- Average comments per pull request: 2.27
- Merged pull requests: 10
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 32
- Pull requests: 2
- Average time to close issues: about 1 month
- Average time to close pull requests: 5 days
- Issue authors: 9
- Pull request authors: 1
- Average comments per issue: 0.5
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- cmspinto (30)
- Milldaz (19)
- colinpmillar (18)
- lucalamoni (14)
- martinezinigo (10)
- RuthFG (10)
- neil-ices-dk (9)
- odontaster (5)
- LApetre (3)
- slarge (2)
- ChunChen001 (2)
- iagomosqueira (2)
- pcrjoana (1)
- arni-magnusson (1)
- timearl (1)
Pull Request Authors
- colinpmillar (11)
- lucalamoni (2)
- jimhester (1)
- arni-magnusson (1)
Top Labels
Issue Labels
SAG (15)
bug (14)
Advice View (10)
R package (9)
ASD (7)
Priority 1 (6)
Web service suggestion (5)
Documentation (4)
SAG-SID (3)
Long Term Dev (3)
DOI (1)
Priority 2 (1)
Template (1)
SAG-TAF (1)
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 525 last-month
- Total dependent packages: 0
- Total dependent repositories: 3
- Total versions: 12
- Total maintainers: 1
cran.r-project.org: icesSAG
Stock Assessment Graphs Database Web Services
- Homepage: https://sg.ices.dk
- Documentation: http://cran.r-project.org/web/packages/icesSAG/icesSAG.pdf
- License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
-
Latest release: 1.6.2
published about 1 year ago
Rankings
Forks count: 8.7%
Dependent repos count: 16.5%
Stargazers count: 17.4%
Average: 22.7%
Dependent packages count: 28.7%
Downloads: 42.5%
Maintainers (1)
Last synced:
10 months ago
Dependencies
DESCRIPTION
cran
- R >= 2.10 depends
- httr * imports
- icesVocab * imports
- openssl * imports
- png * imports
- xml2 * imports
- testthat * suggests