Skip to content

Commit

Permalink
version 0.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
smwoodman authored and cran-robot committed Aug 10, 2023
1 parent e3a8ca3 commit 9f08abf
Show file tree
Hide file tree
Showing 11 changed files with 1,094 additions and 551 deletions.
12 changes: 6 additions & 6 deletions DESCRIPTION
@@ -1,6 +1,6 @@
Package: swfscDAS
Title: Southwest Fisheries Science Center Shipboard DAS Data Processing
Version: 0.6.1
Version: 0.6.2
Authors@R:
person("Sam", "Woodman", email = "sam.woodman@noaa.gov", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-6071-8186"))
Description: Process and summarize shipboard
Expand All @@ -13,16 +13,16 @@ URL: https://smwoodman.github.io/swfscDAS/,
https://github.com/smwoodman/swfscDAS/
BugReports: https://github.com/smwoodman/swfscDAS/issues/
Depends: R (>= 4.0.0)
Imports: dplyr, lubridate, magrittr, methods, parallel, purrr, readr,
rlang, sf, swfscMisc, tidyr
Imports: dplyr (>= 1.1.0), lubridate, magrittr, methods, parallel,
purrr, readr, rlang, sf, swfscMisc, tidyr
Suggests: knitr, rmarkdown, stringr, testthat (>= 2.1.0)
License: CC0
Encoding: UTF-8
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2022-01-31 19:23:23 UTC; sam.woodman
Packaged: 2023-08-08 23:34:27 UTC; sam.woodman
Author: Sam Woodman [aut, cre] (<https://orcid.org/0000-0001-6071-8186>)
Maintainer: Sam Woodman <sam.woodman@noaa.gov>
Repository: CRAN
Date/Publication: 2022-01-31 19:50:02 UTC
Date/Publication: 2023-08-10 07:00:02 UTC
20 changes: 10 additions & 10 deletions MD5
@@ -1,6 +1,6 @@
6c62aa665e827c2dbfbacfc51e644035 *DESCRIPTION
2dba93c5f274f2ce6a36fa11ae741852 *NAMESPACE
65e67d6e38b443fcf8661fb8471508f9 *NEWS.md
102bbc6779e4f8d156a59063b07e4d4a *DESCRIPTION
10e42513eee3c462e23b4e4640234e56 *NAMESPACE
2bca52b91acfa31da9b853a55b8e09ed *NEWS.md
102266fa9dd1be4dfcddcf7a603b4d62 *R/as_das_df.R
1e4cba8a7d8da74119d7012247866623 *R/as_das_dfr.R
41efa05eba27e51ef7d4117b7745693d *R/das_check.R
Expand All @@ -17,14 +17,14 @@ c418ed6b1524e453015f178111ee8a16 *R/das_effort_strata.R
c0648eb11398f305921cf697009adedb *R/das_process.R
ea4549aa913deb4902f1ad0833fee956 *R/das_read.R
37f5ff79244213e016b624e04090564a *R/das_segdata.R
bbbc8546e49f9a377e099592bca691ed *R/das_sight.R
d02b5b2390d050adda047aa70e49e7d5 *R/das_sight.R
ce7d7c6cb53836f6b4b9b891b24747e4 *R/distance_greatcircle.R
d1632370a5a33bd5f35db26a0ce42da9 *R/randpicks_convert.R
6c3088d16042b73f6c2a2ea1ea2f534d *R/subsetting.R
a13f59f7aab865b75d633d6969103c54 *R/swfscDAS-internal.R
5076a5e29db8a50290844c47e878bbf7 *R/swfscDAS-package.R
35abc67baf9094dd0da3defc2d5a6072 *README.md
72642f8b1d5f15a2e03248acbfc9bd05 *build/vignette.rds
a80867b1be9c12bb070c9daf03778070 *R/swfscDAS-package.R
2908c42189b954e8a886ed088cb59d1a *README.md
241d2b461d173c2f167578080d0e9f3e *build/vignette.rds
dd00f8695b1893fbd071e5dfdda1fd21 *inst/DAS_Format.pdf
019d2c4a47e87035cddc8ec511bffee7 *inst/DAS_chop_equallength_figures.pdf
ad585d78881d3eb2512fadfd80370e11 *inst/Ship_sample.dat
Expand All @@ -34,10 +34,10 @@ ad585d78881d3eb2512fadfd80370e11 *inst/Ship_sample.dat
18a11c4354a278365ad9e9861a9751e5 *inst/das_sample_stratum.csv
b5c224f276415b32bb94148851164805 *inst/doc/DAS_data_join.R
682b2d5c6fd4bed582338b2d254f0614 *inst/doc/DAS_data_join.Rmd
b51f4ca95c7a17da9e10e3ced70c5bee *inst/doc/DAS_data_join.html
84db6baae0e84012310efaf166f4f0c1 *inst/doc/DAS_data_join.html
8f7244d93b3101114c1555b29dc53b78 *inst/doc/swfscDAS.R
e4ee86caaf4778899b2b06a07d1a3935 *inst/doc/swfscDAS.Rmd
ceb8d824e307a5b5c098ea75e0852817 *inst/doc/swfscDAS.html
1a672926522a1d2c963b5a5b43b7eacf *inst/doc/swfscDAS.html
acb9dda27e69da9f5fda5956ed84638b *man/as_das_df.Rd
bca1a04e09d1b5d5ba65e26dcc90a68b *man/as_das_dfr.Rd
a368461ed7c8e921c970d1f54b7e836f *man/das_check.Rd
Expand All @@ -55,7 +55,7 @@ b24e29c860a2ef260d0c1fd34cbcb9d8 *man/das_dfr-class.Rd
eecec7a83534b0f53cda76b318c9e8d5 *man/das_process.Rd
5dae722319d5c57a7b46a6eb0a304a3a *man/das_read.Rd
8a17926f90a088e283340cc4a188d15d *man/das_segdata.Rd
45db8c0c00b147bbe302434aba1d13ea *man/das_sight.Rd
7caab785545223e560f1ed8d0bd5a8aa *man/das_sight.Rd
02fe9ad730065f37020f8d5b6e13ee5c *man/distance_greatcircle.Rd
1a14ec3976ce02b3ccad4c7ae7299c9b *man/randpicks_convert.Rd
c774a3c1d6219d824e8a1e078080c5b2 *man/subsetting.Rd
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Expand Up @@ -74,6 +74,7 @@ importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,n)
importFrom(dplyr,n_distinct)
importFrom(dplyr,reframe)
importFrom(dplyr,right_join)
importFrom(dplyr,select)
importFrom(dplyr,slice)
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
@@ -1,3 +1,10 @@
# swfscDAS 0.6.2

* Use `reframe` in grouping summaries in `das_sight` for when none of a certain event are in the data (#8)

* Ensure that `sum(GsSpx)` equals `GsSchoolx`, for all of Best, High and Low (#9)


# swfscDAS 0.6.1

* Fix bug in `das_sight` and `das_effort` when the DAS file contains no sightings
Expand Down
83 changes: 53 additions & 30 deletions R/das_sight.R
Expand Up @@ -21,7 +21,7 @@
#' marine mammal subgroup sightings (code "G"),
#' marine mammal subgroup resights (code "g"),
#' turtle sightings (code "t"),
#' pinniped sightings (code "p")
#' pinniped sightings (code "p"),
#' and fishing vessel sightings (code "F").
#' Warnings are printed if all S, K, M, and G events (and only these events) are not
#' followed by an A event and at least one numeric event.
Expand Down Expand Up @@ -99,11 +99,13 @@
#'
#' SightNoDaily is a running count of the number of S/K/M/G sightings that occurred on each day.
#' It is formatted as 'YYYYMMDD'_'running count', e.g. "20050101_1".
#'
#' The GsSchoolBest, GsSchoolHigh, and GsSchoolLow columns are either:
#' 1) the arithmetic mean across observer estimates for the "default" and "wide" formats, or
#' 2) the individual observer estimates for the "complete" format.
#' 1) the arithmetic mean across observer estimates, for the "default" and "wide" formats, or
#' 2) the individual observer estimates, for the "complete" format.
#' Note that for non-"complete" formats, \code{na.rm = TRUE} is used when calculating the mean,
#' and thus blank elements of estimates (but not the whole incomplete estimate) are ignored.
#'
#' To convert the perpendicular distance back to nautical miles,
#' one would divide PerpDistKm by 1.852
#'
Expand All @@ -120,13 +122,19 @@
#' Species code \tab SpCode \tab Boat type or mammal, turtle, or pinniped species codes\cr
#' Probable species code \tab SpCodeProb \tab Probable mammal species codes; \code{NA} if none or not applicable\cr
#' Group size of species - best estimate \tab GsSpBest \tab
#' Arithmetic mean, across observer estimates, of the product(s) of GsSchoolBest and the corresponding species percentage\cr
#' The product of the arithmetic means of GsSchoolBest and the corresponding species percentage\cr
#' Group size of species - high estimate \tab GsSpHigh \tab
#' Arithmetic mean, across observer estimates, of the product(s) of GsSchoolHigh and the corresponding species percentage\cr
#' The product of the arithmetic means of GsSchoolHigh and the corresponding species percentage\cr
#' Group size of species - low estimate \tab GsSpLow \tab
#' Arithmetic mean, across observer estimates, of the product(s) of GsSchoolLow and the corresponding species percentage\cr
#' The product of the arithmetic means of GsSchoolLow and the corresponding species percentage\cr
#' }
#'
#' Note that for the above calculations,
#' the GsSchoolX value and corresponding species percentages were each
#' averaged across observers, using \code{na.rm = TRUE},
#' before being multiplied to calculate GsSpX. For example, in the workflow:
#' \code{GsSpBest1 = mean(.data$Data2, na.rm = TRUE) * mean(.data$Data5, na.rm = TRUE)}
#'
#' @section The "wide" and "complete" format outputs:
#' The "wide" and "complete" options have very similar columns in their output date frames.
#' There are two main differences: 1) the "wide" format has one row for each sighting event,
Expand Down Expand Up @@ -171,7 +179,8 @@
#' For the "wide" format, ObsEstimate is a list-column of all of the observer codes
#' that provided an estimate.
#' Also in the "wide" format, the GsSpBest# columns are the product of
#' GsSchoolBest and the corresponding species percentage.
#' the means of GsSchoolBest and the corresponding species percentage
#' (see the Default section for calculation details).
#' These numbers, 1 to 4, correspond to the order of the data as it appears in the DAS file
#'
#' @examples
Expand All @@ -197,6 +206,8 @@ das_sight.data.frame <- function(x, ...) {
das_sight.das_df <- function(x, return.format = c("default", "wide", "complete"),
return.events = c("S", "K", "M", "G", "s", "k", "m", "g", "t", "p", "F"),
...) {
mean_narm <- function(i) mean(i, na.rm = TRUE)

#----------------------------------------------------------------------------
return.format <- match.arg(return.format)
return.events <- match.arg(return.events, several.ok = TRUE)
Expand Down Expand Up @@ -322,9 +333,9 @@ das_sight.das_df <- function(x, return.format = c("default", "wide", "complete")
sight.info.skmg3 <- sight.df %>%
filter(.data$Event %in% c("?")) %>%
group_by(.data$sight_cumsum) %>%
summarise(Prob = TRUE,
SpCodeProb1 = .data$Data5, SpCodeProb2 = .data$Data6,
SpCodeProb3 = .data$Data7, SpCodeProb4 = .data$Data8)
reframe(Prob = TRUE,
SpCodeProb1 = .data$Data5, SpCodeProb2 = .data$Data6,
SpCodeProb3 = .data$Data7, SpCodeProb4 = .data$Data8)


# Data from numeric events (groupsize and composition estimates)
Expand All @@ -350,26 +361,38 @@ das_sight.das_df <- function(x, return.format = c("default", "wide", "complete")
Data6 = as.numeric(.data$Data6), Data7 = as.numeric(.data$Data7),
Data8 = as.numeric(.data$Data8)) %>%
group_by(.data$sight_cumsum) %>%
summarise(ObsEstimate = list(.data$Data1),
SpPerc1 = mean(.data$Data5, na.rm = TRUE),
SpPerc2 = mean(.data$Data6, na.rm = TRUE),
SpPerc3 = mean(.data$Data7, na.rm = TRUE),
SpPerc4 = mean(.data$Data8, na.rm = TRUE),
GsSchoolBest = mean(.data$Data2, na.rm = TRUE),
GsSchoolHigh = mean(.data$Data3, na.rm = TRUE),
GsSchoolLow = mean(.data$Data4, na.rm = TRUE),
GsSpBest1 = mean(.data$Data2 * .data$Data5 / 100, na.rm = TRUE),
GsSpBest2 = mean(.data$Data2 * .data$Data6 / 100, na.rm = TRUE),
GsSpBest3 = mean(.data$Data2 * .data$Data7 / 100, na.rm = TRUE),
GsSpBest4 = mean(.data$Data2 * .data$Data8 / 100, na.rm = TRUE),
GsSpHigh1 = mean(.data$Data3 * .data$Data5 / 100, na.rm = TRUE),
GsSpHigh2 = mean(.data$Data3 * .data$Data6 / 100, na.rm = TRUE),
GsSpHigh3 = mean(.data$Data3 * .data$Data7 / 100, na.rm = TRUE),
GsSpHigh4 = mean(.data$Data3 * .data$Data8 / 100, na.rm = TRUE),
GsSpLow1 = mean(.data$Data4 * .data$Data5 / 100, na.rm = TRUE),
GsSpLow2 = mean(.data$Data4 * .data$Data6 / 100, na.rm = TRUE),
GsSpLow3 = mean(.data$Data4 * .data$Data7 / 100, na.rm = TRUE),
GsSpLow4 = mean(.data$Data4 * .data$Data8 / 100, na.rm = TRUE))
reframe(ObsEstimate = list(.data$Data1),
SpPerc1 = mean_narm(.data$Data5),
SpPerc2 = mean_narm(.data$Data6),
SpPerc3 = mean_narm(.data$Data7),
SpPerc4 = mean_narm(.data$Data8),
GsSchoolBest = mean_narm(.data$Data2),
GsSchoolHigh = mean_narm(.data$Data3),
GsSchoolLow = mean_narm(.data$Data4),
GsSpBest1 = mean_narm(.data$Data2) * mean_narm(.data$Data5) / 100,
GsSpBest2 = mean_narm(.data$Data2) * mean_narm(.data$Data6) / 100,
GsSpBest3 = mean_narm(.data$Data2) * mean_narm(.data$Data7) / 100,
GsSpBest4 = mean_narm(.data$Data2) * mean_narm(.data$Data8) / 100,
GsSpHigh1 = mean_narm(.data$Data3) * mean_narm(.data$Data5) / 100,
GsSpHigh2 = mean_narm(.data$Data3) * mean_narm(.data$Data6) / 100,
GsSpHigh3 = mean_narm(.data$Data3) * mean_narm(.data$Data7) / 100,
GsSpHigh4 = mean_narm(.data$Data3) * mean_narm(.data$Data8) / 100,
GsSpLow1 = mean_narm(.data$Data4) * mean_narm(.data$Data5) / 100,
GsSpLow2 = mean_narm(.data$Data4) * mean_narm(.data$Data6) / 100,
GsSpLow3 = mean_narm(.data$Data4) * mean_narm(.data$Data7) / 100,
GsSpLow4 = mean_narm(.data$Data4) * mean_narm(.data$Data8) / 100)
# GsSpBest1 = mean(.data$Data2 * .data$Data5 / 100, na.rm = TRUE),
# GsSpBest2 = mean(.data$Data2 * .data$Data6 / 100, na.rm = TRUE),
# GsSpBest3 = mean(.data$Data2 * .data$Data7 / 100, na.rm = TRUE),
# GsSpBest4 = mean(.data$Data2 * .data$Data8 / 100, na.rm = TRUE),
# GsSpHigh1 = mean(.data$Data3 * .data$Data5 / 100, na.rm = TRUE),
# GsSpHigh2 = mean(.data$Data3 * .data$Data6 / 100, na.rm = TRUE),
# GsSpHigh3 = mean(.data$Data3 * .data$Data7 / 100, na.rm = TRUE),
# GsSpHigh4 = mean(.data$Data3 * .data$Data8 / 100, na.rm = TRUE),
# GsSpLow1 = mean(.data$Data4 * .data$Data5 / 100, na.rm = TRUE),
# GsSpLow2 = mean(.data$Data4 * .data$Data6 / 100, na.rm = TRUE),
# GsSpLow3 = mean(.data$Data4 * .data$Data7 / 100, na.rm = TRUE),
# GsSpLow4 = mean(.data$Data4 * .data$Data8 / 100, na.rm = TRUE))
}

if (!all(sight.info.skmg1$sight_cumsum %in% sight.info.skmg4$sight_cumsum))
Expand Down
2 changes: 1 addition & 1 deletion R/swfscDAS-package.R
Expand Up @@ -13,7 +13,7 @@
#'
#' @importFrom dplyr add_row arrange between bind_cols bind_rows case_when desc
#' distinct everything filter full_join group_by if_else
#' lag left_join mutate n n_distinct
#' lag left_join mutate n n_distinct reframe
#' right_join select slice starts_with summarise ungroup
#' @importFrom lubridate year month day tz
#' @importFrom magrittr %>%
Expand Down
14 changes: 1 addition & 13 deletions README.md
Expand Up @@ -7,9 +7,7 @@

[![CRAN
version](http://www.r-pkg.org/badges/version/swfscDAS)](https://cran.r-project.org/package=swfscDAS)
[![R-CMD-check](https://github.com/smwoodman/swfscDAS/workflows/R-CMD-check/badge.svg)](https://github.com/smwoodman/swfscDAS/actions)
<!-- [![Travis build status](https://travis-ci.com/smwoodman/swfscDAS.svg?branch=master)](https://travis-ci.com/smwoodman/swfscDAS)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/smwoodman/swfscDAS?branch=master&svg=true)](https://ci.appveyor.com/project/smwoodman/swfscDAS) -->
[![R-CMD-check](https://github.com/smwoodman/swfscDAS/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/smwoodman/swfscDAS/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

This package contains functions designed for processing and analyzing
Expand Down Expand Up @@ -38,16 +36,6 @@ You can install the developmental version of swfscDAS from
remotes::install_github("smwoodman/swfscDAS")
```

Before installing swfscDAS, you must have
[R](https://www.r-project.org/),
[RStudio](https://www.rstudio.com/products/rstudio/download/), and the
appropriate version of
[Rtools](https://cran.r-project.org/bin/windows/Rtools/) installed. When
installing the developmental version, it is best practice to install
after closing all instances of R and RStudio, and then running the
install code from the R GUI rather than RStudio. Please contact the
developer if you have any issues.

## DAS data format

swfscDAS expects data to follow the conventions and format used by the
Expand Down
Binary file modified build/vignette.rds
Binary file not shown.

0 comments on commit 9f08abf

Please sign in to comment.