Skip to content

Commit

Permalink
only comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sgaichas committed Sep 19, 2024
1 parent 54fe90b commit 2f6fdc5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions R/get_herring_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ get_herring_data <- function(channel, comland, filterByYear, filterByArea,
#Aggregate data
data.table::setkey(herr.catch, YEAR, MONTH, CATEGORY, STOCK_AREA, NEGEAR)

# SKG Sept 2024
# This keeps kept and discarded separate in the herring object
# Discards are dropped below. Do we want to keep discards for later?
herring <- herr.catch[, list(sum(KEPTMT, na.rm = T), sum(DISCMT, na.rm = T)),
by = key(herr.catch)]


data.table::setnames(herring, c('STOCK_AREA', 'V1', 'V2'),
c('AREA', 'SPPLIVMT', 'DISCMT'))
Expand All @@ -66,13 +70,16 @@ get_herring_data <- function(channel, comland, filterByYear, filterByArea,
herring.comland <- comland[NESPP3 == 168, ]

#Price from comland
# SKG there is no price before 1982--all values are 0
# because SPPVALUE is NA in StockEff before then?
herring.price <- herring.comland[, (sum(SPPVALUE, na.rm = T) / sum(SPPLIVMT, na.rm = T)),
by = c('YEAR', 'MONTH')]

data.table::setnames(herring.price, 'V1', 'price')

herring <- merge(herring, herring.price, by = c('YEAR', 'MONTH'), all.x = T)

# SKG there is no price before 1982--all values are 0
#Use 1964 prices for < 1964
herring[YEAR < 1964, price := mean(herring[YEAR == 1964, price])]
#Calculate SPPVALUE from price
Expand Down

0 comments on commit 2f6fdc5

Please sign in to comment.