Skip to contents

Collapse data frame from haul to trip

Usage

haul_to_trip(
  dat,
  project,
  fun.numeric = mean,
  fun.time = mean,
  tripID,
  haul_count = TRUE,
  log_fun = TRUE
)

Arguments

dat

Primary data containing information on hauls or trips. Table in the FishSET database contains the string 'MainDataTable'.

project

String, name of project.

fun.numeric

How to collapse numeric or temporal data. For example, min, mean, max, sum. Defaults to mean.

fun.time

How to collapse temporal data. For example, min, mean, max. Cannot be sum for temporal variables.

tripID

Column(s) that identify the individual trip.

haul_count

Logical, whether to return a column of the number of hauls per trip.

log_fun

Logical, whether to log function call (for internal use).

Value

Returns the primary dataset where each row is a trip.

Details

Collapses primary dataset from haul to trip level. Unique trips are defined based on selected column(s), for example, landing permit number and disembarked port. This id column is used to collapse the data to trip level. fun.numeric and fun.time define how multiple observations for a trip are collapsed. For variables that are not numeric or dates, the first observation is used.

Examples

if (FALSE) {
pollockMainDataTable <- haul_to_trip("pollockMainDataTable","pollock",
    min, mean, "PERMIT", "DISEMBARKED_PORT"
    )
}