Learn R Programming

Tivy (version 0.1.1)

add_variables: Add variables for juveniles, sample length, distance to coast, and distance category

Description

Adds new variables to a dataset, including the proportion of juveniles, the total number of individuals in the sample, the distance to the coast, and the distance category.

Usage

add_variables(
  data,
  JuvLim = 12,
  distance_type = "haversine",
  window = 0.5,
  unit = "nm",
  coastline = NULL,
  suppress_warnings = TRUE
)

Value

Data frame with new variables: juv (proportion of juveniles), sample (total individuals), dc (distance to coast), and dc_cat (categorical distance).

Arguments

data

Data frame that must contain latitude (lat_initial) and longitude (lon_initial) coordinates, as well as columns with individual length.

JuvLim

Length threshold to consider juveniles.

distance_type

Type of distance calculation to the coast.

window

Window parameter to smooth the coastline.

unit

Distance unit used in the calculation ("nm", "km", etc.).

coastline

Data frame with coastline coordinates. Must have columns named Long and Lat. If NULL, uses internal dataset peru_coastline.

suppress_warnings

Logical. If TRUE, warnings are suppressed.

Examples

Run this code
if (FALSE) {
data_hauls <- process_hauls(data_hauls = calas_bitacora)
data_fishing_trips <- process_fishing_trips(data_fishing_trips = faenas_bitacora)
hauls_length <- process_length(data_length = tallas_bitacora)

data_length_trips <- merge(
  x = data_fishing_trips, 
  y = hauls_length, 
  by = 'fishing_trip_code'
)
data_total <- merge_length_fishing_trips_hauls(
  data_hauls = data_hauls, 
  data_length_fishing_trips = data_length_trips
)

results <- add_variables(data = data_total)
}

Run the code above in your browser using DataLab