Skip to content

Commit

Permalink
New zbar(FLStock) method
Browse files Browse the repository at this point in the history
  • Loading branch information
iagomosqueira committed Jul 8, 2024
1 parent d8d6e9e commit 50239b7
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: FLCore
Title: Core Package of FLR, Fisheries Modelling in R
Version: 2.6.20.9200
Version: 2.6.20.9201
Authors@R: c(
person("Iago", "Mosqueira", email = "iago.mosqueira@wur.nl",
role = "cre", comment=c(c(ORCID = "0000-0002-3252-0591"))),
Expand Down
13 changes: 7 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,10 @@ exportMethods(
"rlnorm",
"rlog",
"rlogstandard",
"rngyear",
"rngyear<-",
"rngage",
"rngage<-",
"rnoise",
"rnorm",
"rpois",
Expand Down Expand Up @@ -617,6 +621,8 @@ exportMethods(
"vcost<-",
"vcov",
"vcov<-",
"vecyear",
"vecage",
"verify",
"window",
"wt",
Expand All @@ -628,11 +634,6 @@ exportMethods(
"yearTotals",
"yearVars",
"z",
"rngyear",
"rngyear<-",
"rngage",
"rngage<-",
"vecyear",
"vecage",
"zbar",
"weighted.mean",
"wireframe")
23 changes: 23 additions & 0 deletions R/FLStock.R
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,29 @@ setMethod("fbar", signature(object="FLStock"),
}
) # }}}

# zbar {{{
setMethod("zbar", signature(object="FLStock"),
function(object, ...) {

rng <- range(object)

if (is.na(rng["minfbar"]))
rng["minfbar"] <- rng["min"]

if (is.na(rng["maxfbar"]))
rng["maxfbar"] <- rng["max"]

rng["minfbar"] <- max(rng["min"], min(rng["max"], rng["minfbar"]))
rng["maxfbar"] <- max(rng["min"], min(rng["max"], rng["maxfbar"]))

if(units(harvest(object)) == 'f' || units(harvest(object)) == 'hr')
{
return(quantMeans(z(object)[as.character(rng["minfbar"]:rng["maxfbar"]),]))
} else
stop("Correct units (f or hr) not specified in the harvest slot")
}
) # }}}

# hr {{{
setMethod("hr", signature(object="FLStock"),
function(object, ...) {
Expand Down
4 changes: 4 additions & 0 deletions R/genericMethods.R
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,10 @@ setGeneric("computeHarvest", function(object, catch, ...)
setGeneric("fbar", function(object, ...)
standardGeneric("fbar"))

# zbar
setGeneric("zbar", function(object, ...)
standardGeneric("zbar"))

# ssbpurec
setGeneric("ssbpurec", function(object, ...)
standardGeneric("ssbpurec"))
Expand Down

0 comments on commit 50239b7

Please sign in to comment.