R/long2taf.R

Defines functions long2taf

Documented in long2taf

#' Convert Long Table to TAF Format
#'
#' Convert a table from long format to TAF format.
#'
#' @param x a data frame in long format.
#'
#' @return A data frame in TAF format.
#'
#' @note
#' TAF stores tables as data frames, usually with a year column as seen in stock
#' assessment reports. The long format is more convenient for analysis and
#' producing plots.
#'
#' @seealso
#' \code{\link{catage.long}} and \code{\link{catage.taf}} describe the long and
#' TAF formats.
#'
#' \code{\link{taf2long}} converts a TAF table to long format.
#'
#' \code{\link{TAF-package}} gives an overview of the package.
#'
#' @examples
#' long2taf(catage.long)
#'
#' @importFrom stats xtabs
#'
#' @export

long2taf <- function(x)
{
  y <- xtabs(x[[3]]~x[[1]]+x[[2]])
  xtab2taf(y)
}

Try the TAF package in your browser

Any scripts or data that you put into this service are public.

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