sam2taf: Convert SAM Table to TAF Format

Description Usage Arguments Details Value Note See Also Examples

View source: R/sam2taf.R

Description

Convert a table from SAM format to TAF format.

Usage

1
sam2taf(x, colname = NULL, year = TRUE)

Arguments

x

a matrix containing columns Estimate, Low, and High.

colname

a descriptive column name for the output.

year

whether to include a year column.

Details

The default when colname = NULL is to try to infer a column name from the x argument. For example,

1
2
3
sam2taf(ssbtable(fit))
sam2taf(ssb)
sam2taf(SSB)

will recognize ssbtable calls and ssb object names, implicitly setting colname = "SSB" if the user does not pass an explicit value for colname.

Value

A data frame in TAF format.

Note

The stockassessment package provides accessor functions that return a matrix with columns Estimate, Low, and High, while TAF tables are stored as data frames with a year column.

See Also

summary.taf describes the TAF format.

catchtable, fbartable, rectable, ssbtable, and tsbtable (in the stockassessment package) return matrices with SAM estimates and confidence limits.

The summary method for sam objects produces a summary table with some key quantities of interest, containing duplicated column names (Low, High) and rounded values.

TAF-package gives an overview of the package.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Example objects
x <- as.matrix(summary.taf[grep("SSB", names(summary.taf))])
rec <- as.matrix(summary.taf[grep("Rec", names(summary.taf))])
tsb <- as.matrix(summary.taf[grep("TSB", names(summary.taf))])
dimnames(x) <- list(summary.taf$Year, c("Estimate", "Low", "High"))
dimnames(rec) <- dimnames(tsb) <- dimnames(x)

## One SAM table, arbitrary object name
sam2taf(x)
sam2taf(x, "SSB")
sam2taf(x, "SSB", year=FALSE)

## Many SAM tables, recognized names
sam2taf(rec)
data.frame(sam2taf(rec), sam2taf(tsb, year=FALSE))

## Not run: 

## Accessing tables from SAM fit object
data.frame(sam2taf(rectable(fit)), sam2taf(tsbtable(fit), year=FALSE))

## End(Not run)

TAF documentation built on April 7, 2021, 5:06 p.m.