From fbaf7871230c84a4e0284c3c188ce45d4bfa5653 Mon Sep 17 00:00:00 2001 From: Derek Ogle Date: Mon, 21 May 2018 22:02:40 -0500 Subject: [PATCH] Added aStandard and StdIntLit --- .Rbuildignore | 1 + NAMESPACE | 1 + NEWS.md | 2 + R/StdIntLit.R | 17 +++ R/aStandard.R | 32 ++++++ _pkgdown.yml | 4 + data-raw/StdIntLit.R | 3 + data-raw/StdIntLit.csv | 13 +++ data/StdIntLit.RData | Bin 0 -> 329 bytes docs/news/index.html | 4 + docs/pkgdown.yml | 3 + docs/reference/StdIntLit.html | 183 +++++++++++++++++++++++++++++++ docs/reference/aStandard.html | 191 +++++++++++++++++++++++++++++++++ docs/reference/bcFuns.html | 4 +- docs/reference/index.html | 12 +++ docs/sitemap.xml | 69 ++++++++++++ man/StdIntLit.Rd | 26 +++++ man/aStandard.Rd | 29 +++++ tests/testthat/test_MESSAGES.R | 7 ++ tests/testthat/test_OUTPUTS.R | 30 ++++-- 20 files changed, 621 insertions(+), 10 deletions(-) create mode 100644 R/StdIntLit.R create mode 100644 R/aStandard.R create mode 100644 data-raw/StdIntLit.R create mode 100644 data-raw/StdIntLit.csv create mode 100644 data/StdIntLit.RData create mode 100644 docs/reference/StdIntLit.html create mode 100644 docs/reference/aStandard.html create mode 100644 docs/sitemap.xml create mode 100644 man/StdIntLit.Rd create mode 100644 man/aStandard.Rd diff --git a/.Rbuildignore b/.Rbuildignore index b06b40f..d0e1623 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -9,3 +9,4 @@ ^README\.md ^\.travis\.yml$ ^appveyor\.yml$ +^data-raw$ diff --git a/NAMESPACE b/NAMESPACE index 83421cb..873ac34 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,7 @@ # Generated by roxygen2: do not edit by hand export(RFBCoptions) +export(aStandard) export(addRadCap) export(backCalc) export(bcFuns) diff --git a/NEWS.md b/NEWS.md index 82ec089..51fbf17 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,7 @@ * Added tests. * Updated "Collect Data" vignette for changes to `combineData()`. * Changed "Back-calculating Lengths" vignette for new `backCalc()`. +* `aStandard()`: Added. Addresses [#10](https://github.com/droglenc/RFishBC/issues/10). * `backCalc()`: Added. * `bcFuns()`: Modified. Changed to using `STOP()`. Changed all `Lc` to `Lcap`, `Rc` to `Rcap`, `agec` to `Acap`, and `agei` to `Ai`. Changed all BPH-related models to use `a`, `b`, and `c` and all SPH-related odels to use `A`, `B`, and `C`. Started using `iGetBCMethod()`. Removed `verbose=` (moved to within the returned function). * `bcUtilChecker()`: Modified. Changed to using `STOP()` and `WARN()`. @@ -13,6 +14,7 @@ * `iGetBCMethod()`: Added. Used in `backCalc()` and `bcFuns()`. * `SMBassWB1`: Added. * `SMBassWB2`: Added. +* `StdIntLit`: Added. # RFishBC 0.0.8 13-May-18 * Added tests. diff --git a/R/StdIntLit.R b/R/StdIntLit.R new file mode 100644 index 0000000..82757a8 --- /dev/null +++ b/R/StdIntLit.R @@ -0,0 +1,17 @@ +#' @title Standard intercepts for Fraser-Lee model by species. +#' +#' @description Standard intercepts (in mm) for Fraser-Lee model for all species for which the standard has been defined. +#' +#' @format A data frame with 1 rows and 3 variables: +#' \describe{ +#' \item{species}{Fish species.} +#' \item{a}{Standard intercept value (in mm).} +#' \item{source}{Source of the standard.} +#' } +#' +#' @references Beck, H.D., D.W. Willis, and J.M. Francis. 1997. A proposed standard intercept for the White Bass body length-scale relationship. North American Journal of Fisheries Management 32:239-248. +#' +#' Carlander, K.D. 1982. Standard intercepts for calculating lengths from scale measurements for some centrarchid and percid fishes. Transactions of the American Fisheries Society 111:333-336. +#' +#' @seealso \code{\link{aStandard}} +"StdIntLit" \ No newline at end of file diff --git a/R/aStandard.R b/R/aStandard.R new file mode 100644 index 0000000..9831fa7 --- /dev/null +++ b/R/aStandard.R @@ -0,0 +1,32 @@ +#' @title Finds standard intercept (a) for Fraser-Lee back-calculation model for a particular species. +#' +#' @description Finds standard intercept (a; mm) for Fraser-Lee back-calculation model for a particular species for all species for which a value of a has been defined. +#' +#' @param species A string that contains the species name for which to find teh standard intercept value. +#' @return A single value from \code{\link{StdIntLit}} that is the standard intercept value (a; mm) for the species provided in \code{species}. +#' +#' @author Derek H. Ogle, \email{derek@@derekogle.com} +#' +#' @seealso \code{\link{StdIntLit}} +#' +#' @keywords manip +#' +#' @examples +#' aStandard("Bluegill") +#' aStandard("Walleye") +#' +#' @export +aStandard <- function(species) { + # Load StdIntLit data frame into this function's environment. The data/get + # combination are used to avoide the "no global binding" note at CHECK + StdIntLit <- get(utils::data("StdIntLit",envir=environment()),envir=environment()) + # Check species + if (missing(species)) STOP("'species' must be one of: ", + paste(StdIntLit$species,collapse=", ")) + species <- FSA::capFirst(species) + if (length(species)>1) STOP("Can have only one name in 'species'.") + if (!species %in% StdIntLit$species) STOP("'species' must be one of: ", + paste(StdIntLit$species,collapse=", ")) + # Return a for that species + StdIntLit$a[StdIntLit==species] +} diff --git a/_pkgdown.yml b/_pkgdown.yml index 58c79e2..07f1f23 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,5 +1,7 @@ title: RFishBC +url: http://derekogle.com/RFishBC + authors: Derek H. Ogle: href: http://derekogle.com @@ -25,6 +27,7 @@ reference: contents: - backCalc - bcFuns + - aStandard - title: Utilities desc: Functions to perform miscellaneous utilities. contents: @@ -36,6 +39,7 @@ reference: contents: - SMBassWB1 - SMBassWB2 + - StdIntLit navbar: type: inverse diff --git a/data-raw/StdIntLit.R b/data-raw/StdIntLit.R new file mode 100644 index 0000000..9c30bcd --- /dev/null +++ b/data-raw/StdIntLit.R @@ -0,0 +1,3 @@ +StdIntLit <- read.csv("data-raw/StdIntLit.csv",stringsAsFactors=FALSE) +str(StdIntLit) +save(StdIntLit,file="data/StdIntLit.RData") diff --git a/data-raw/StdIntLit.csv b/data-raw/StdIntLit.csv new file mode 100644 index 0000000..cb38c88 --- /dev/null +++ b/data-raw/StdIntLit.csv @@ -0,0 +1,13 @@ +species,a,source +Black Crappie,35,Carlander (1982) +Bluegill,20,Carlander (1982) +Green Sunfish,10,Carlander (1982) +Largemouth Bass,20,Carlander (1982) +Pumpkinseed,25,Carlander (1982) +Rock Bass,25,Carlander (1982) +Smallmouth Bass,35,Carlander (1982) +Walleye,55,Carlander (1982) +Warmouth,20,Carlander (1982) +White Bass,40,Beck et al. (1997) +White Crappie,35,Carlander (1982) +Yellow Perch,30,Carlander (1982) diff --git a/data/StdIntLit.RData b/data/StdIntLit.RData new file mode 100644 index 0000000000000000000000000000000000000000..8531e565d827fc19da015fb6d59444cf6c22cb7d GIT binary patch literal 329 zcmV-P0k-}hiwFP!000002HjG>PXaL%E*z+w5Qw_Cm`hx6xkMIZJxq)V1Aze?U+x}U zL+?l0UWl82w6o_c^bFwS>hRuczkdDt+OMpdh;S(aTQyzI{~@IBrA06 z1)!9LFQ-M4Z+NN@qpFEnMn@cQy7L5t__g(XK`6febg=-r^$_g3csYED@#e0bgbR*EcKw4=S(cwvzD#@r;TOTuCj$Tg`U9SM literal 0 HcmV?d00001 diff --git a/docs/news/index.html b/docs/news/index.html index 049d447..5506e7e 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -132,6 +132,8 @@

  • Updated “Collect Data” vignette for changes to combineData().
  • Changed “Back-calculating Lengths” vignette for new backCalc().
  • +aStandard(): Added. Addresses #10.
  • +
  • backCalc(): Added.
  • bcFuns(): Modified. Changed to using STOP(). Changed all Lc to Lcap, Rc to Rcap, agec to Acap, and agei to Ai. Changed all BPH-related models to use a, b, and c and all SPH-related odels to use A, B, and C. Started using iGetBCMethod(). Removed verbose= (moved to within the returned function).
  • @@ -147,6 +149,8 @@

    SMBassWB1: Added.
  • SMBassWB2: Added.
  • +
  • +StdIntLit: Added.
  • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 6c722c5..a7c0cdc 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -7,4 +7,7 @@ articles: BCIntro: BCIntro/BCIntro.html collectRadiiData: MeasureRadii/collectRadiiData.html seeRadiiData: MeasureRadii/seeRadiiData.html +urls: + reference: http://derekogle.com/RFishBC/reference + article: http://derekogle.com/RFishBC/articles diff --git a/docs/reference/StdIntLit.html b/docs/reference/StdIntLit.html new file mode 100644 index 0000000..206577a --- /dev/null +++ b/docs/reference/StdIntLit.html @@ -0,0 +1,183 @@ + + + + + + + + +Standard intercepts for Fraser-Lee model by species. — StdIntLit • RFishBC + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Standard intercepts (in mm) for Fraser-Lee model for all species for which the standard has been defined.

    + +
    + +
    StdIntLit
    + +

    Format

    + +

    A data frame with 1 rows and 3 variables:

    +
    species

    Fish species.

    +
    a

    Standard intercept value (in mm).

    +
    source

    Source of the standard.

    +
    + +

    References

    + +

    Beck, H.D., D.W. Willis, and J.M. Francis. 1997. A proposed standard intercept for the White Bass body length-scale relationship. North American Journal of Fisheries Management 32:239-248. +Carlander, K.D. 1982. Standard intercepts for calculating lengths from scale measurements for some centrarchid and percid fishes. Transactions of the American Fisheries Society 111:333-336.

    + +

    See also

    + + + + +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + + + + diff --git a/docs/reference/aStandard.html b/docs/reference/aStandard.html new file mode 100644 index 0000000..f64b7bb --- /dev/null +++ b/docs/reference/aStandard.html @@ -0,0 +1,191 @@ + + + + + + + + +Finds standard intercept (a) for Fraser-Lee back-calculation model for a particular species. — aStandard • RFishBC + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + +
    +
    + + +
    + +

    Finds standard intercept (a; mm) for Fraser-Lee back-calculation model for a particular species for all species for which a value of a has been defined.

    + +
    + +
    aStandard(species)
    + +

    Arguments

    + + + + + + +
    species

    A string that contains the species name for which to find teh standard intercept value.

    + +

    Value

    + +

    A single value from StdIntLit that is the standard intercept value (a; mm) for the species provided in species.

    + +

    See also

    + + + + +

    Examples

    +
    aStandard("Bluegill")
    #> [1] 20
    aStandard("Walleye")
    #> [1] 55
    +
    +
    + +
    + +
    + + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + + + + diff --git a/docs/reference/bcFuns.html b/docs/reference/bcFuns.html index ca141fd..8f5e8f9 100644 --- a/docs/reference/bcFuns.html +++ b/docs/reference/bcFuns.html @@ -188,7 +188,7 @@

    Examp #> if (verbose) DONE("Using the Dahl-Lea model.") #> (Ri/Rcap)*Lcap #> } -#> <environment: 0x1b1a5750>

    bcm1(20,10,40)
    #> <U+2714> Using the Dahl-Lea model.
    #> [1] 5
    +#> <environment: 0x1ae5f190>
    bcm1(20,10,40)
    #> <U+2714> Using the Dahl-Lea model.
    #> [1] 5
    ## Example with dummy length-at-cap, radii-at-cap, and radii-at-age lencap <- c(100,100,100,150,150) radcap <- c(20,20,20,30,30) @@ -198,7 +198,7 @@

    Examp #> if (verbose) DONE("Using the Fraser-Lee model with a=",a,".") #> a+(Lcap-a)*(Ri/Rcap) #> } -#> <environment: 0x1b2de978>

    bcm2(lencap,rad,radcap,2) # demonstrated with a=2
    #> <U+2714> Using the Fraser-Lee model with a=2.
    #> [1] 26.5000 51.0000 75.5000 76.0000 125.3333
    +#> <environment: 0x1bbf43c8>
    bcm2(lencap,rad,radcap,2) # demonstrated with a=2
    #> <U+2714> Using the Fraser-Lee model with a=2.
    #> [1] 26.5000 51.0000 75.5000 76.0000 125.3333