fish_stat_week: Calculate statistical week from date values

Description Usage Arguments Examples

View source: R/data_manipulation.R

Description

Generates a flavor of statistical week values typically encountered in fisheries management related applications. Allows the start date of the stat week to be set to either Sunday or Monday. Stat weeks will always be numbered starting at one on the first day of the year.

Usage

1
fish_stat_week(dts, start_day = "Mon")

Arguments

dts

A vector of date values formatted as character

start_day

Starting day of the stat week. Options are "Mon" or "Sun"

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Generate a vector of date values
dtv = seq(as.Date("2017-01-01"),
          as.Date("2017-01-15"),
          by = "day")

# Generate vector of stat week values
stat_week = fish_stat_week(dtv)

# Create dataframe with date values
fish_catch = tibble::tibble(survey_date = dtv,
                            catch = as.integer(abs(rnorm(length(dtv)) * 10)))

# Add a stat_week column to fish_catch
fish_catch$stat_week = fish_stat_week(fish_catch$survey_date)

arestrom/remisc documentation built on July 16, 2020, 8:48 a.m.