record_grooming_rule: record_grooming_rule

View source: R/grooming.R

record_grooming_ruleR Documentation

record_grooming_rule

Description

record_grooming_rule

Usage

record_grooming_rule(
  df,
  index,
  catch.col,
  record = NULL,
  rule,
  year.col = NULL,
  attribute = "catch",
  keep_NA = T
)

Arguments

df

the df we are manipulating

index

a conditional index length(index) == nrow(df). TRUE means it stays, FALSE means it is being excluded from

catch.col

column label for the catch variable

record

a data.frame to append the summaries to.

rule

the label for the grooming rule (string)

year.col

column label for the year variable. Can be ommited, if supplied the Data.frame will break down catch and number of events removed from each grooming rule by year.

attribute

if by year specify the attribute to record

  • catch absoulte catch

  • events number of events

  • relative_catch is the percent change in catch from applying the rule

  • relative_events is the percent change in number of events from applying the rule

  • cumulative_catch track the catch left in the data set after each grooming rule

  • cumulative_events track the events left in the data set after each grooming rule

keep_NA

if index has NA's and this is true then they stay in the data

Details

a utility function to record the effect of grooming rules on data sets. It will note remove the index from the dataset. TODO: As well as recording the effect of a groomong rule on catch and number of records summarise spatail distribution.

Value

the record data frame with new entries for the grooming rule

Examples

## Not run: 
## example of plotting this output
## plot records
melt_total = melt(total_grooming_record, id.vars = "rule")
melt_total$rule = factor(melt_total$rule, ordered = T, levels = total_grooming_record$rule)
ggplot(melt_total %>% filter(variable %in%  c("events", "catch")), 
      aes(y = value /1000, x = rule, group = 1)) +
 geom_line(size = 2, linetype = "dotted") +
 geom_point(size = 4, aes(col = rule)) + 
 theme(axis.text.x = element_blank()) +
 ylab("") +
 ylim(0,1600) +
 facet_wrap(~variable) +
 xlab("")

## End(Not run)

Craig44/stockassessmenthelper documentation built on April 14, 2023, 10:57 a.m.