tapsum: tapsum simplifies the use of tapply for summarizing variables

View source: R/cpuefuncs.r

tapsumR Documentation

tapsum simplifies the use of tapply for summarizing variables

Description

data exploration commonly uses the tapply function and tapsum simplifies its use when obtaining the sum of any variable relative to other variables. For example it is common to want the total catch by year and, for example, Month, DepCat, Zone, etc.

Usage

tapsum(indat, first, second, third = NA, div = 1000)

Arguments

indat

the data.frame containing the raw fishery data

first

the variable name (in quotes) being summed

second

the first grouping variable

third

the second grouping variable, defaults to NA

div

defaults to 1000 to change Kg to tonnes. set to 1.0 or NA to avoid its influence

Value

a vector or matrix of sums of the pickvar by the first and optionally the second grouping variable

Examples

## Not run: 
  data(sps)
  tapsum(sps,"catch_kg","Year","Month")

## End(Not run)

haddonm/rforcpue documentation built on Oct. 12, 2024, 11:55 p.m.