Skip to content

Commit

Permalink
Added sources to PSDlit and related modifications (fixes #76 )
Browse files Browse the repository at this point in the history
  • Loading branch information
droglenc committed May 21, 2021
1 parent b90d527 commit 83adaa8
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 99 deletions.
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* `paletteChoices()`: Removed. See `chooseColors()` above. Partially addresses [#65](https://github.com/droglenc/FSA/issues/65).
* `psdAdd()`: Modified. Changed a `levels()` in `iPSDlitCheck()` to `unique()` because `species` is no longer a factor due to updating `PSDlit` (i.e., rdata file changed with new `read.csv()`).
* `psdCalc()`: Modified. Added a catch for when "tibble"s are sent in `data=` (addresses [#75](https://github.com/droglenc/FSA/issues/75)).
* `PSDlit`: Modified. Added length categories for Shoal Bass. Added Striped Bass (Hybrid) and Striped Bass x White Bass; though these are the same as the existing Palmetto Bass.
* `psdVal()`: Modified. Changed a `levels()` in `iPSDlitCheck()` and `iListSpecies()` to `unique()` because `species` is no longer a factor due to updating `PSDlit` (i.e., rdata file changed with new `read.csv()`).
* `PSDlit`: Modified. Added length categories for Shoal Bass and Pallid Sturgeon. Added Striped Bass (Hybrid) and Striped Bass x White Bass; though these are the same as the existing Palmetto Bass. Added "source"s for each entry.
* `psdVal()`: Modified. Changed a `levels()` in `iPSDlitCheck()` and `iListSpecies()` to `unique()` because `species` is no longer a factor due to updating `PSDlit` (i.e., rdata file changed with new `read.csv()`). Added a `showJustSource=` argument that will show the source info (if `TRUE`) or not (if `FALSE`; default), which partially addresses [#76](https://github.com/droglenc/FSA/issues/76).
* `removal()`: Modified. Added check and then warning if non-whole numbers are in `catch=` (addresses [#60](https://github.com/droglenc/FSA/issues/60)). Also modified checks of data integrity to be more robust (e.g., if a character vector is sent).
* `residPlot()`: Modified. Removed use of `chooseColors()` (see above).
* `Subset()`: Removed. Added to `FSA-defunct`. Partially addresses [#65](https://github.com/droglenc/FSA/issues/65).
Expand Down
1 change: 1 addition & 0 deletions R/PSDlit.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#' \item{preferred.cm}{Preferred length in cm.}
#' \item{memorable.cm}{Memorable length in cm.}
#' \item{trophy.cm}{Trophy length in cm.}
#' \item{source}{Literature source for the length entries.}
#' }
#'
#' @section Topic(s):
Expand Down
64 changes: 35 additions & 29 deletions R/psdVal.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' @param incl.zero A logical that indicates if a zero is included in the first position of the returned vector (DEFAULT) or not. This position will be named \dQuote{substock}. See details.
#' @param addLens A numeric vector that contains minimum length definitions for additional categories. See details.
#' @param addNames A string vector that contains names for the additional length categories added with \code{addLens}. See details.
#' @param showJustSource A logical that indicates whether just the literature source information should be returned (\code{TRUE}) or not. If \code{TRUE} this will NOT return any of the Gabelhouse length information.
#'
#' @details Finds the Gabelhouse lengths from \code{data(PSDlit)} for the species given in \code{species}. The species name must be spelled exactly (within capitalization differences) as it appears in \code{data(PSDlit)}. Type \code{psdVal()} to see the list of species and how they are spelled.
#'
Expand Down Expand Up @@ -50,45 +51,50 @@
#' psdVal("Bluegill",units="in",addLens=c(7,9),addNames=c("MinSlot","MaxSlot"))
#' psdVal("Bluegill",units="in",addLens=c("MinLen"=7))
#' psdVal("Bluegill",units="in",addLens=c("MinSlot"=7,"MaxSlot"=9))
#' psdVal("Bluegill",showJustSource=TRUE)
#'
#' @export psdVal
psdVal <- function(species="List",units=c("mm","cm","in"),incl.zero=TRUE,
addLens=NULL,addNames=NULL) {
addLens=NULL,addNames=NULL,showJustSource=FALSE) {
units <- match.arg(units)
# load RSDlit data frame into this function's environment
# data/get combination are used to avoid the "no global binding" note at CHECK
PSDlit <- get(utils::data("PSDlit",envir=environment()),envir=environment())
# continue if species name is correct
if (iPSDLitCheck(PSDlit,species <- capFirst(species))) {
# identify columns based on units
ifelse(units=="in",cols <- 2:6,cols <- 7:11)
# get the length categories
PSDvec <- as.matrix(PSDlit[PSDlit$species==species,cols])[1,]
# convert to mm if necessary
if (units=="mm") PSDvec <- PSDvec*10
names(PSDvec) <- c("stock","quality","preferred","memorable","trophy")
# add a zero category if asked to
if (incl.zero) {
PSDvec <- c(0,PSDvec)
names(PSDvec)[1] <- "substock"
}
# add additional lengths if asked to
if (!is.null(addLens)) {
# add names to the addLens vector
addLens <- iHndlAddNames(addLens,addNames)
# handle duplicated values
tmp <- which(PSDvec %in% addLens)
if (length(tmp>0)) {
WARN("At least one Gabelhouse length that was in 'addLens' has been removed.")
PSDvec <- PSDvec[-tmp]
if (showJustSource) {
PSDlit[PSDlit$species==species,c(1,12)]
} else {
# identify columns based on units
ifelse(units=="in",cols <- 2:6,cols <- 7:11)
# get the length categories
PSDvec <- as.matrix(PSDlit[PSDlit$species==species,cols])[1,]
# convert to mm if necessary
if (units=="mm") PSDvec <- PSDvec*10
names(PSDvec) <- c("stock","quality","preferred","memorable","trophy")
# add a zero category if asked to
if (incl.zero) {
PSDvec <- c(0,PSDvec)
names(PSDvec)[1] <- "substock"
}
# append the new lens to the Gabelhouse lengths
PSDvec <- c(PSDvec,addLens)
# re-order so the new values are within the Gabelhouse lengths
PSDvec <- PSDvec[order(PSDvec)]
}
PSDvec
}
# add additional lengths if asked to
if (!is.null(addLens)) {
# add names to the addLens vector
addLens <- iHndlAddNames(addLens,addNames)
# handle duplicated values
tmp <- which(PSDvec %in% addLens)
if (length(tmp>0)) {
WARN("At least one Gabelhouse length that was in 'addLens' has been removed.")
PSDvec <- PSDvec[-tmp]
}
# append the new lens to the Gabelhouse lengths
PSDvec <- c(PSDvec,addLens)
# re-order so the new values are within the Gabelhouse lengths
PSDvec <- PSDvec[order(PSDvec)]
}
PSDvec
}
}
}


Expand Down
135 changes: 68 additions & 67 deletions data-raw/PSDlit.csv
Original file line number Diff line number Diff line change
@@ -1,67 +1,68 @@
species,stock.in,quality.in,preferred.in,memorable.in,trophy.in,stock.cm,quality.cm,preferred.cm,memorable.cm,trophy.cm
Arctic Grayling,8,12,16,20,22,20,30,40,50,55
Bighead Carp,11.75,21.25,26.75,35,43.75,30,54,68,89,111
Bigmouth Buffalo,11,18,24,30,37,28,46,61,76,94
Black Bullhead,6,9,12,15,18,15,23,30,39,46
Black Carp,15.75,28.25,35.5,46.5,58.25,40,72,90,118,148
Black Crappie,5,8,10,12,15,13,20,25,30,38
Blue Catfish,12,20,30,35,45,30,51,76,89,114
Bluegill,3,6,8,10,12,8,15,20,25,30
Brook Trout (lentic),8,13,NA,NA,NA,20,33,NA,NA,NA
Brook Trout (lotic),5,8,NA,NA,NA,13,20,NA,NA,NA
Brook Trout,8,12,16,20,24,20,30,40,50,60
Brown Bullhead,5,8,11,14,17,13,20,28,36,43
Brown Trout (lentic),8,12,16,20,24,20,30,40,50,60
Brown Trout (lotic),6,9,12,15,18,15,23,30,38,46
Bull Trout,8,16,20,26,31,20,40,50,65,80
Burbot,8,15,21,26,32,20,38,53,67,82
Chain Pickerel,10,15,20,25,30,25,38,51,63,76
Channel Catfish,11,16,24,28,36,28,41,61,71,91
Chinook Salmon (landlocked),11,18,24,30,37,28,46,61,76,94
Common Carp,11,16,21,26,33,28,41,53,66,84
Cutthroat Trout,8,14,18,24,30,20,35,45,60,75
Flathead Catfish,14,20,28,34,40,35,51,71,86,102
Freshwater Drum,8,12,15,20,25,20,30,38,51,63
Gizzard Shad,7,11,NA,NA,NA,18,28,NA,NA,NA
Golden Trout,8,10,14,18,22,20,25,35,45,55
Grass Carp,11.75,21.25,26.75,35,43.75,30,54,68,89,111
Green Sunfish,3,6,8,10,12,8,15,20,25,30
Kokanee,8,10,12,16,20,12,25,30,40,50
Lake Trout,12,20,26,31,39,30,50,65,80,100
Largemouth Bass,8,12,15,20,25,20,30,38,51,63
Longnose Gar,16,27,36,45,55,41,69,91,114,140
Muskellunge,20,30,38,42,50,51,76,97,107,127
Northern Pike,14,21,28,34,44,35,53,71,86,112
Paddlefish,16,26,33,41,51,41,66,84,104,130
Pumpkinseed,3,6,8,10,12,8,15,20,25,30
Rainbow Trout,10,16,20,26,31,25,40,50,65,80
Redear Sunfish,4,7,9,11,13,10,18,23,28,33
River Carpsucker,7,11,14,18,22,18,28,36,46,56
Rock Bass,4,7,9,11,13,10,18,23,28,33
Ruffe,2.2,3.5,4.7,5.5,6.9,5.5,9,12,14,17.5
Sauger,8,12,15,20,25,20,30,38,51,63
Saugeye,9,14,15,22,27,23,35,46,56,69
Shoal Bass,7.1,11,13.8,16.9,20.1,18,28,35,43,51
Shorthead Redhorse,6,10,13,16,20,15,25,33,41,51
Silver Carp,10,17.75,22,29,36.5,25,45,56,74,93
Smallmouth Bass,7,11,14,17,20,18,28,35,43,51
Smallmouth Buffalo ,11,18,24,30,37,28,46,61,76,94
Splake,8,10,14,16,22,20,25,35,40,55
Spotted Bass,7,11,14,17,20,18,28,35,43,51
Spotted Gar,12,19,25,31,39,30,48,64,79,99
Striped Bass (landlocked),12,20,30,35,45,30,51,76,89,114
Suwannee Bass,6,9.75,11.75,13.75,15.75,15,25,30,35,40
Walleye,10,15,20,25,30,25,38,51,63,76
Warmouth,3,6,8,10,12,8,15,20,25,30
White Bass,6,9,12,15,18,15,23,30,38,46
Palmetto Bass,10,16,20,24,28,25,41,51,61,71
Palmetto Bass (original),8,12,15,20,25,20,30,38,51,63
White Catfish,8,13,17,21,26,20,33,43,53,66
White Crappie,5,8,10,12,15,13,20,25,30,38
White Perch,5,8,10,12,35,13,20,25,30,38
White Sucker,6,10,13,16,20,15,25,33,41,51
Yellow Perch,5,8,10,12,15,13,20,25,30,38
Yellow Bass,4,7,9,11,13,10,18,23,28,33
Yellow Bullhead,4,7,9,11,14,10,18,23,28,36
Striped Bass (hybrid),10,16,20,24,28,25,41,51,61,71
Striped Bass X White Bass,10,16,20,24,28,25,41,51,61,71
species,stock.in,quality.in,preferred.in,memorable.in,trophy.in,stock.cm,quality.cm,preferred.cm,memorable.cm,trophy.cm,source
Arctic Grayling,8,12,16,20,22,20,30,40,50,55,Hyatt (2000)
Bighead Carp,11.75,21.25,26.75,35,43.75,30,54,68,89,111,Phelps and Willis (2013)
Bigmouth Buffalo,11,18,24,30,37,28,46,61,76,94,Bister et al. (2000)
Black Bullhead,6,9,12,15,18,15,23,30,39,46,Gabelhouse (1984a)
Black Carp,15.75,28.25,35.5,46.5,58.25,40,72,90,118,148,Phelps and Willis (2013)
Black Crappie,5,8,10,12,15,13,20,25,30,38,Gabelhouse (1984a)
Blue Catfish,12,20,30,35,45,30,51,76,89,114,Gabelhouse (1984a)
Bluegill,3,6,8,10,12,8,15,20,25,30,Gabelhouse (1984a)
Brook Trout (lentic),8,13,NA,NA,NA,20,33,NA,NA,NA,Anderson (1980)
Brook Trout (lotic),5,8,NA,NA,NA,13,20,NA,NA,NA,Anderson (1980)
Brook Trout,8,12,16,20,24,20,30,40,50,60,Hyatt (2000)
Brown Bullhead,5,8,11,14,17,13,20,28,36,43,Bister et al. (2000)
Brown Trout (lentic),8,12,16,20,24,20,30,40,50,60,Hyatt and Hubert (2001)
Brown Trout (lotic),6,9,12,15,18,15,23,30,38,46,Milewski and Brown (1994)
Bull Trout,8,16,20,26,31,20,40,50,65,80,Hyatt (2000)
Burbot,8,15,21,26,32,20,38,53,67,82,Fisher et al. (1996)
Chain Pickerel,10,15,20,25,30,25,38,51,63,76,Gabelhouse (1984a)
Channel Catfish,11,16,24,28,36,28,41,61,71,91,Gabelhouse (1984a)
Chinook Salmon (landlocked),11,18,24,30,37,28,46,61,76,94,Hill and Duffy (1993)
Common Carp,11,16,21,26,33,28,41,53,66,84,Gabelhouse (1984a)
Cutthroat Trout,8,14,18,24,30,20,35,45,60,75,Kruse and Hubert (1997)
Flathead Catfish,14,20,28,34,40,35,51,71,86,102,Quinn (1991)
Freshwater Drum,8,12,15,20,25,20,30,38,51,63,Gabelhouse (1984a)
Gizzard Shad,7,11,NA,NA,NA,18,28,NA,NA,NA,Anderson and Gutreuter (1983)
Golden Trout,8,10,14,18,22,20,25,35,45,55,Hyatt (2000)
Grass Carp,11.75,21.25,26.75,35,43.75,30,54,68,89,111,Phelps and Willis (2013)
Green Sunfish,3,6,8,10,12,8,15,20,25,30,Gabelhouse (1984a)
Kokanee,8,10,12,16,20,12,25,30,40,50,Hyatt (2000)
Lake Trout,12,20,26,31,39,30,50,65,80,100,Hubert et al. (1994)
Largemouth Bass,8,12,15,20,25,20,30,38,51,63,Gabelhouse (1984a)
Longnose Gar,16,27,36,45,55,41,69,91,114,140,Bister et al. (2000)
Muskellunge,20,30,38,42,50,51,76,97,107,127,Gabelhouse (1984a)
Northern Pike,14,21,28,34,44,35,53,71,86,112,Gabelhouse (1984a)
Paddlefish,16,26,33,41,51,41,66,84,104,130,Brown and Murphy (1993)
Pallid Sturgeon,13,25,33,41,50,33,63,84,104,147,Shuman et al. (2006)
Palmetto Bass,10,16,20,24,28,25,41,51,61,71,Dumont and Neely (2011)
Palmetto Bass (original),8,12,15,20,25,20,30,38,51,63,Gabelhouse (1984a)
Pumpkinseed,3,6,8,10,12,8,15,20,25,30,Gabelhouse (1984a)
Rainbow Trout,10,16,20,26,31,25,40,50,65,80,Simpkins and Hubert (1996)
Redear Sunfish,4,7,9,11,13,10,18,23,28,33,Gabelhouse (1984a)
River Carpsucker,7,11,14,18,22,18,28,36,46,56,Bister et al. (2000)
Rock Bass,4,7,9,11,13,10,18,23,28,33,Gabelhouse (1984a)
Ruffe,2.2,3.5,4.7,5.5,6.9,5.5,9,12,14,17.5,Ogle and Winfield (2009)
Sauger,8,12,15,20,25,20,30,38,51,63,Gabelhouse (1984a)
Saugeye,9,14,15,22,27,23,35,46,56,69,Gabelhouse (1984a)
Shoal Bass,7.1,11,13.8,16.9,20.1,18,28,35,43,51,Bonvechio et al. (2019)
Shorthead Redhorse,6,10,13,16,20,15,25,33,41,51,Bister et al. (2000)
Silver Carp,10,17.75,22,29,36.5,25,45,56,74,93,Phelps and Willis (2013)
Smallmouth Bass,7,11,14,17,20,18,28,35,43,51,Gabelhouse (1984a)
Smallmouth Buffalo ,11,18,24,30,37,28,46,61,76,94,Bister et al. (2000)
Splake,8,10,14,16,22,20,25,35,40,55,Hyatt (2000)
Spotted Bass,7,11,14,17,20,18,28,35,43,51,Gabelhouse (1984a)
Spotted Gar,12,19,25,31,39,30,48,64,79,99,Bister et al. (2000)
Striped Bass (landlocked),12,20,30,35,45,30,51,76,89,114,Gabelhouse (1984a)
Striped Bass (hybrid),10,16,20,24,28,25,41,51,61,71,Dumont and Neely (2011)
Striped Bass X White Bass,10,16,20,24,28,25,41,51,61,71,Dumont and Neely (2011)
Suwannee Bass,6,9.75,11.75,13.75,15.75,15,25,30,35,40,Bonvechio et al. (2010)
Walleye,10,15,20,25,30,25,38,51,63,76,Gabelhouse (1984a)
Warmouth,3,6,8,10,12,8,15,20,25,30,Gabelhouse (1984a)
White Bass,6,9,12,15,18,15,23,30,38,46,Gabelhouse (1984a)
White Catfish,8,13,17,21,26,20,33,43,53,66,Bister et al. (2000)
White Crappie,5,8,10,12,15,13,20,25,30,38,Gabelhouse (1984a)
White Perch,5,8,10,12,35,13,20,25,30,38,Gabelhouse (1984a)
White Sucker,6,10,13,16,20,15,25,33,41,51,Bister et al. (2000)
Yellow Perch,5,8,10,12,15,13,20,25,30,38,Gabelhouse (1984a)
Yellow Bass,4,7,9,11,13,10,18,23,28,33,Anderson and Gutreuter (1983)
Yellow Bullhead,4,7,9,11,14,10,18,23,28,36,Anderson (1980)
Binary file modified data/PSDlit.rdata
Binary file not shown.
1 change: 1 addition & 0 deletions man/PSDlit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion man/psdVal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/testthat/testthat_PSD.R
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ test_that("psdVal() returns",{
expect_equivalent(tmp,c(0,130,200,250,300,380))
expect_equal(names(tmp),c("substock","stock","quality","preferred",
"memorable","trophy"))
tmp <- psdVal("yellow Perch",showJustSource=TRUE)
expect_is(tmp,"data.frame")
expect_equivalent(ncol(tmp),2)
expect_equivalent(nrow(tmp),1)
})

test_that("psdCI() returns",{
Expand Down

0 comments on commit 83adaa8

Please sign in to comment.