Skip to content

Commit

Permalink
reomved rd files for functions no longer exported
Browse files Browse the repository at this point in the history
  • Loading branch information
andybeet committed Sep 14, 2024
1 parent d89de26 commit 66716b7
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 250 deletions.
186 changes: 93 additions & 93 deletions R/assign_unknown.R

Large diffs are not rendered by default.

39 changes: 19 additions & 20 deletions R/calc_DK.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#' Calculate discard to kept ratio
#'
#' Use observer data to calculate the ratio of discards to kept by species.
#'
#'
# @inheritParams strat_prep
#' @param na.keep Boolean. Logical value to indicate whether original strata names
#' should be retained.
#' @inheritParams get_comland_data
#' @param comData data frame. calculated from inside \code{get_comdisc_data}
#'
#' @return Returns a \code{comdiscData} data.table with one additional column labeled
#' with the value of \code{areaDescription}
Expand All @@ -15,49 +13,50 @@
#'
#' @importFrom magrittr "%>%"
#'
#'@family comdisc
#' @family comdisc
#'
#' @export
#' Internal function
#' @noRd



calc_DK <- function(comData, areaDescription, fleetDescription){

comdata <- data.table::copy(comData[[1]])

#Standardize column names
comdata <- data.table::setnames(comdata, c(areaDescription, fleetDescription),
comdata <- data.table::setnames(comdata, c(areaDescription, fleetDescription),
c('area', 'fleet'))

#sum catch by species/disposition/area/fleet
ob.sums <- comdata[, sum(SPPLIVMT), by = c('YEAR', 'area', 'fleet', 'NESPP3',
'CATDISP')]
#identify discards
ob.discard <- ob.sums[CATDISP == 0, ]

setnames(ob.discard, "V1", "DISCARD")
ob.discard[, CATDISP := NULL]

#Sum kept by area/fleet
ob.kept <- ob.sums[CATDISP == 1, sum(V1), by = c('YEAR', 'area', 'fleet')]

setnames(ob.kept, "V1", "KEPT.ALL")

#Merge discards and kept
dk <- merge(ob.kept, ob.discard, by = c('YEAR', 'area', 'fleet'))

#Calculate ratio
dk[, DK := DISCARD / KEPT.ALL]
#NAs result if divide by 0 so set DK to 1 (all discards)
dk[is.na(DK), DK := 1.0]

#Remove extra columns
dk[, c('KEPT.ALL', 'DISCARD') := NULL]

#Replace standard column names
#Standardize column names
data.table::setnames(dk, c('area', 'fleet'),
data.table::setnames(dk, c('area', 'fleet'),
c(areaDescription, fleetDescription))

return(dk[])
}

31 changes: 10 additions & 21 deletions R/calc_discards.R
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
#' Calculate stratified mean
#' Calculates total discard by species
#'
#' Calculates the stratified mean. Details of method found here ...
#' Applies discard ratio to landings to obtain total discards by species
#'
#' @inheritParams strat_prep
#' @inheritParams strat_mean
#' @param tidy Boolean. Return output in long format (Default = F).
#' @param returnPrepData Boolean. Return both \code{stratmeanData} and \code{prepData}
#' as a list object. The default (F) returns only the \code{stratmeanData} as a
#' \code{data.table}.
#' @inheritParams get_comland_data
#' @param comland Data frame. Internally calculated by \code{get_comdisc_data}
#' @param dk dk. Need to find out
#'
#' @return
#'
#'@family survdat
#' @return dk
#'
#'@family comdisc
#'
#' @examples
#' \dontrun{
#' # Pull data and apply conversion corrections
#' data <- get_survdat_data(channel)
#' # Calculate stratified mean for specific survey strata for the SPRING season
#' calc_stratified_mean(surveyData=data$survdat, filterByArea=c(1220, 1240, 1260:1290,1360:1400),filterBySeason = "SPRING")
#'
#' # Calculate stratified mean for area defined by EPU regions, for all seasons ("SPRING", "FALL")
#' # Read in EPU shapefile (loaded as part of the package)
#' area <- sf::st_read(dsn = system.file("extdata","EPU.shp",package="survdat"),quiet=T)
#' calc_stratified_mean(surveyData=data$survdat, areaPolygon=area, areaDescription="EPU", filterByArea="all",filterBySeason = "all")
#'
#' }
#'
#'
#' @export
#' Internal function
#' @noRd


calc_discards <- function(comland, dk, areaDescription, fleetDescription) {
Expand Down
15 changes: 15 additions & 0 deletions R/soeAreas.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#' soeAreas: Area Species,EPU designations
#'
#' Option to pass to \code{get_comland_data} if the user wishes define EPUs exclusively
#' by Stat areas and not to proportion the landings in these Statistical areas to EPUs
#'
#' @format A Data frame
#' \describe{
#' \item{AREA}{Statistical Area}
#' \item{NESPP3}{Gulf of Maine EPU}
#' \item{MeanProp}{Proportion of Statistical area to attribute to EPU}
#' \item{EPU}{Ecological Production Unit}
#'}
#'
#'
"soeAreas"
27 changes: 0 additions & 27 deletions man/assign_area.Rd

This file was deleted.

27 changes: 0 additions & 27 deletions man/assign_unknown.Rd

This file was deleted.

27 changes: 0 additions & 27 deletions man/calc_DK.Rd

This file was deleted.

35 changes: 0 additions & 35 deletions man/calc_discards.Rd

This file was deleted.

0 comments on commit 66716b7

Please sign in to comment.