Version: | 4.2.0 |
Title: | Functions to Support the ICES Transparent Assessment Framework |
Imports: | purrr, roxygen2, TAF (≥ 4.2.0), data.tree |
Suggests: | git2r |
LazyData: | yes |
Description: | Functions to support the ICES Transparent Assessment Framework https://taf.ices.dk to organize data, methods, and results used in ICES assessments. ICES is an organization facilitating international collaboration in marine science. |
License: | GPL-3 |
URL: | https://taf.ices.dk, https://github.com/ices-tools-prod/icesTAF |
Encoding: | UTF-8 |
RoxygenNote: | 7.2.3 |
NeedsCompilation: | no |
Packaged: | 2023-03-21 13:40:20 UTC; colin |
Author: | Colin Millar [aut, cre], Arni Magnusson [aut], Alexandros Kokkalis [ctb], Iago Mosqueira [ctb], Ibrahim Umar [ctb], Hjalte Parner [ctb] |
Maintainer: | Colin Millar <colin.millar@ices.dk> |
Repository: | CRAN |
Date/Publication: | 2023-03-21 14:00:02 UTC |
Functions to Support the ICES Transparent Assessment Framework
Description
Functions to support the ICES Transparent Assessment Framework, to organize data, methods, and results used in ICES assessments.
Details
Initial TAF steps:
draft.data.script | create boot script |
taf.roxygenise | create DATA.bib entry from tags |
Author(s)
Colin Millar and Arni Magnusson.
References
ICES Transparent Assessment Framework: https://taf.ices.dk.
To explore example TAF stock assessments, see the introductory video and tutorial.
The TAF Wiki provides additional help resources.
Import a boot data script from ICES datasets repo
Description
Download an ‘R’ file from the ICES datasets repo to fetch data including adding metadata via roxygen2 fields to the top of the file.
Usage
add.data.script(name, install.deps = TRUE, commit = FALSE)
Arguments
name |
the name of the dataset. |
install.deps |
install packages used in the script if not already installed. |
commit |
should the boot script be added and committed to the analysis. |
Examples
## Not run:
# Create boot folder
mkdir(taf.boot.path())
# Create boot script, boot/mydata.R
add.data.script(name = "vms")
# Create metadata, boot/DATA.bib
taf.roxygenise(files = "vms.R")
# Run boot script, creating boot/data/vms/...
taf.boot()
## End(Not run)
Print a directory tree
Description
Print the directory tree and file contents in a pretty way
Usage
dir.tree(path = ".")
Arguments
path |
the directory for which the listing is to be shown |
See Also
Examples
## Not run:
library(icesTAF)
# Download a TAF analysis
dir.tree()
## End(Not run)
Download a TAF analysis
Description
Download the code for a TAF analysis from GitHub.
Usage
download.analysis(repo, dir = tempdir())
Arguments
repo |
The full name of the GitHub repository, e.g. "ices-taf/2019_san.sa.6". |
dir |
the directory to place the TAF project |
See Also
Examples
## Not run:
library(icesTAF)
# Download a TAF analysis
run_dir <- download.analysis("ices-taf/2019_san.sa.6", dir = ".")
# run the analysis
run.analysis(run_dir)
## End(Not run)
Draft or create a boot data script
Description
Create an ‘R’ file to fetch data including adding metadata via roxygen2 fields to the top of the file.
Usage
draft.data.script(name, title, description, format, originator, year, period,
access, content)
Arguments
name |
the name of the dataset and the file name that will be created. |
title |
description of the data, including survey names or the like. |
description |
a more involved description if required. |
format |
the format of the data produced, e.g. "csv" |
originator |
who prepared the data, e.g. a working group acronym. |
year |
year of the analysis when the data were used. The default is the current year. |
period |
a numeric vector of the form |
access |
data access code: |
content |
the r code that fetches and saves the data |
Examples
## Not run:
# Create boot folder
mkdir("boot")
# Create boot script, boot/mydata.R
draft.data.script(name="mydata", title="Title", description="Description",
format="txt", originator="Me", year="2022",
period=c(2000,2020), access="Public",
content='write(pi, file="pi.txt")')
# Create metadata, boot/DATA.bib
taf.roxygenise(files="mydata.R")
# Run boot script, creating boot/data/mydata/pi.txt
taf.boot()
## End(Not run)
Various TAF Helper Functions
Description
These functions are called by user-level functions. The functionality is documented in the user-level functions.
Usage
## S3 method for class 'roxy_tag_tafKey'
roxy_tag_parse(x)
## S3 method for class 'roxy_tag_tafOriginator'
roxy_tag_parse(x)
## S3 method for class 'roxy_tag_tafYear'
roxy_tag_parse(x)
## S3 method for class 'roxy_tag_tafPeriod'
roxy_tag_parse(x)
## S3 method for class 'roxy_tag_tafAccess'
roxy_tag_parse(x)
## S3 method for class 'roxy_tag_tafSource'
roxy_tag_parse(x)
See Also
icesTAF-package
gives an overview of the package.
Install packages dependencies of a TAF analysis
Description
Search R scripts for packages that are required and install them.
Usage
install.deps(path = ".", ...)
Arguments
path |
a directory or file containing R scripts. |
... |
arguments passed on to install.packages |
See Also
Examples
## Not run:
library(icesTAF)
# Download a TAF analysis
download("https://github.com/ices-taf/2019_san.sa.6/archive/refs/heads/master.zip")
unzip("master.zip")
# move into analysis folder
setwd("2019_san.sa.6-master")
# list dependencies
deps()
# install dependencies
install.deps()
## End(Not run)
Run a TAF analysis
Description
Run the code for a TAF analysis locally.
Usage
run.analysis(dir)
Arguments
dir |
the directory where the TAF project is located |
See Also
Examples
## Not run:
library(icesTAF)
# Download a TAF analysis
run_dir <- download.analysis("ices-taf/2019_san.sa.6", dir = ".")
# run the analysis
run.analysis(run_dir)
## End(Not run)
Functions re-exported from the TAF package
Description
These functions are re-exported from the TAF package.
Usage
makeAll(...)
taf.install(targz = NULL, lib = "boot/library", quiet = FALSE)
parse.repo(repo)
taf2long(x, names = c("Year", "Age", "Value"))
write.taf(x, file = NULL, dir = NULL, quote = FALSE, row.names = FALSE,
fileEncoding = "UTF-8", underscore = TRUE, ...)
utf8.to.latin1(file, force = FALSE)
download(url, dir = ".", mode = "wb", chmod = file_ext(url) == "",
destfile = file.path(dir, basename(url)), quiet = TRUE, ...)
clean.boot(force = FALSE)
flr2taf(x, colname = "Value")
get.remote.sha(owner, repo, ref, seven = TRUE)
taf.bootstrap(...)
xtab2taf(x, colname = "Year")
long2taf(x)
source.taf(script, rm = FALSE, clean = TRUE, detach = FALSE,
taf = NULL, quiet = FALSE)
ds.file(package, author, year, title, version, source)
div(x, cols, by = 1000, grep = FALSE, ...)
detach.packages(quiet = FALSE)
rnd(x, cols, digits = 0, grep = FALSE, ...)
taf2xtab(x)
ds.package(package, author, year, title, version, source)
long2xtab(x)
os.linux()
taf.png(filename, width = 1600, height = 1200, res = 200, ...)
os.macos()
os()
period(x, y = NULL)
tt(x, column = FALSE)
clean.data(folder = "boot/data", quiet = FALSE, force = FALSE)
## S3 method for class 'trellis'
zoom(x, size = 1, main = 1.2 * size, lab = size,
axis = size, strip = size, sub = 0.9 * size, legend = 0.9 * size,
splom = 0.9 * size, ...)
zoom(x, ...)
unix2dos(file)
dos2unix(file)
mkdir(path)
convert.spaces(file, sep = "_")
lim(x, mult = 1.1)
is.r.package(targz, spec = NULL, warn = TRUE)
clean.software(folder = "boot/software", quiet = FALSE, force = FALSE)
taf.boot.path(..., fsep = .Platform$file.sep)
sourceAll(...)
plus(x)
taf.sources(type)
msg(...)
process.entry(bib, quiet = FALSE, force = FALSE, clean = FALSE)
taf.data.path(..., fsep = .Platform$file.sep)
download.github(repo, dir = ".", quiet = FALSE)
deps(path = ".", base = FALSE, installed = TRUE, available = TRUE,
list = FALSE)
taf.session(sort = FALSE, imports = TRUE, details = FALSE)
os.unix()
xtab2long(x, names = c("Year", "Age", "Value"))
os.windows()
draft.data(originator = NULL, year = format(Sys.time(), "%Y"),
title = NULL, period = NULL, access = "Public", source = NULL,
file = "", append = FALSE,
data.files = dir(taf.boot.path("initial/data")),
data.scripts = dir(boot.dir(), pattern = "\\.R$"))
read.taf(file, check.names = FALSE, stringsAsFactors = FALSE,
fileEncoding = "UTF-8", ...)
clean(dirs = c("data", model.dir(), "output", "report"), force = FALSE)
model.script()
taf.libPaths(remove = FALSE)
draft.software(package, author = NULL, year = NULL, title = NULL,
version = NULL, source = NULL, file = "", append = FALSE)
sourceDir(...)
taf.boot(software = TRUE, data = TRUE, clean = TRUE, force = FALSE,
taf = NULL, quiet = FALSE)
file.encoding(file)
latin1.to.utf8(file, force = FALSE)
clean.library(folder = "boot/library", quiet = FALSE, force = FALSE)
tafpng(...)
sourceTAF(...)
taf2html(x, file = "", align = "", header = align,
digits = getOption("digits"), center = "style=\"text-align:center\"",
left = "style=\"text-align:left\"",
right = "style=\"text-align:right\"", append = FALSE)
source.all(...)
extract.subdir(targz, subtargz, subdir)
taf.library(package, messages = FALSE, warnings = FALSE)
read.bib(file)
boot.exists()
boot.dir()
stamp.description(targz, spec, sha.full)
make.all(...)
make.taf(script, ...)
make(recipe, prereq, target, include = TRUE, engine = source,
debug = FALSE, force = FALSE, recon = FALSE, ...)
boot.dir.inside(inside = ".")
model.dir()
line.endings(file)
already.in.taf.library(targz, lib)
taf.unzip(zipfile, files = NULL, exdir = ".", unzip = NULL, ...)
process.bibfile(type, clean = TRUE, quiet = FALSE)
cp(from, to, move = FALSE, ignore = FALSE, overwrite = TRUE,
quiet = TRUE)
makeTAF(...)
rmdir(path, recursive = FALSE)
source.dir(dir, pattern = "\\.[r|R]$", all.files = FALSE,
recursive = FALSE, quiet = TRUE, ...)
sam2taf(x, colname = NULL, year = TRUE)
taf.skeleton(path = ".", force = FALSE, pkgs = "icesTAF")
Details
Follow the links below to see the documentation.
makeAll
, taf.install
, parse.repo
, taf2long
, write.taf
, utf8.to.latin1
, download
, clean.boot
, flr2taf
, get.remote.sha
, taf.bootstrap
, xtab2taf
, long2taf
, source.taf
, ds.file
, div
, detach.packages
, rnd
, taf2xtab
, ds.package
, long2xtab
, os.linux
, taf.png
, os.macos
, os
, period
, tt
, clean.data
, zoom.trellis
, zoom
, unix2dos
, dos2unix
, mkdir
, convert.spaces
, lim
, is.r.package
, clean.software
, taf.boot.path
, sourceAll
, plus
, taf.sources
, msg
, process.entry
, taf.data.path
, download.github
, deps
, taf.session
, os.unix
, xtab2long
, os.windows
, draft.data
, read.taf
, clean
, model.script
, taf.libPaths
, draft.software
, sourceDir
, taf.boot
, file.encoding
, latin1.to.utf8
, clean.library
, tafpng
, sourceTAF
, taf2html
, source.all
, extract.subdir
, taf.library
, read.bib
, boot.exists
, boot.dir
, stamp.description
, make.all
, make.taf
, make
, boot.dir.inside
, model.dir
, line.endings
, already.in.taf.library
, taf.unzip
, process.bibfile
, cp
, makeTAF
, rmdir
, source.dir
, sam2taf
TAF Colors
Description
Predefined colors that can be useful in TAF plots.
Usage
taf.green
taf.orange
taf.blue
taf.dark
taf.light
See Also
TAF-package
gives an overview of the package.
Examples
taf.green
opar <- par(mfrow=c(3,1))
barplot(5:1, main="Five",
col=c(taf.green, taf.orange, taf.blue, taf.dark, taf.light))
barplot(6:1, main="Six", col=c(taf.green, taf.orange, taf.blue,
taf.dark, taf.light, "white"))
barplot(7:1, main="Seven", col=c("black", taf.dark, taf.light,
taf.green, taf.orange, taf.blue, "white"))
par(opar)
Process a TAF repo with the taf roclet
Description
This function builds documentation for a TAF repository using roxygen syntax headers. It depends on the roxygen2 package adding some extra functionality to produce citation entries for data sources
Usage
taf.roxygenise(path = ".", files)
Arguments
path |
location of taf repository top level directory. Default is working directory. |
files |
a vector of file names to parse for documentation. |
Examples
## Not run:
# Create boot folder
mkdir("boot")
# Create boot script, boot/mydata.R
draft.data.script(name="mydata", title="Title", description="Description",
format="txt", originator="Me", year="2022",
period=c(2000,2020), access="Public",
content='write(pi, file="pi.txt")')
# Create metadata, boot/DATA.bib
taf.roxygenise(files="mydata.R")
# Run boot script, creating boot/data/mydata/pi.txt
taf.boot()
## End(Not run)
TAF Skeleton
Description
Create initial directories and R scripts for a new TAF analysis using a stock assessment created on stockassessment.org.
Usage
taf.skeleton.sa.org(path = ".", stockname, force = FALSE)
Arguments
path |
where to create initial directories and R scripts. The default is the current working directory. |
stockname |
The short-form name of a stock on stockassessment.org. |
force |
whether to overwrite existing scripts. |
Value
Full path to analysis directory.
See Also
package.skeleton
creates an empty template for a new R package.
TAF-package
gives an overview of the package.
Examples
## Not run:
taf.skeleton.sa.org(stockname = "WBCod_2021_cand01")
## End(Not run)