Skip to content

Commit

Permalink
rework read_formphyto for correct taxa grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
fawda123 committed Oct 27, 2024
1 parent 00eefaa commit 9f7ae44
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: tbeptools
Title: Data and Indicators for the Tampa Bay Estuary Program
Version: 3.0.0.9000
Date: 2024-10-25
Date: 2024-10-27
Authors@R: c(
person(given = "Marcus",
family = "Beck",
Expand Down
14 changes: 7 additions & 7 deletions R/read_formphyto.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#'
#' @importFrom dplyr %>%
#'
#' @details Only seven taxonomic groups are summarized. Pyrodinium bahamense, Karenia brevis, Tripos hircus, Pseudo-nitzschia sp., and Pseudo-nitzschia pungens are retained at the species level. Bacillariophyta and Cyanobacteria are retained at the phylum level. All other taxa are grouped into an "other" category.
#' @details Only seven taxonomic groups are summarized. Pyrodinium bahamense, Karenia brevis, Tripos hircus, Pseudo-nitzschia sp., and Pseudo-nitzschia pungens are retained at the species level. Diatoms are summarized at the class level using Bacillariophyceae, Coscinodiscophyceae, and Mediophyceae and Cyanobacteria are summarized at the phylum level using Cyanobacteriota. All other taxa are grouped into an "other" category.
#'
#' @seealso \code{\link{read_importphyto}}
#'
Expand All @@ -19,7 +19,7 @@
#' xlsx <- '~/Desktop/phyto_data.xlsx'
#'
#' # load and assign to object
#' phytodata <- read_importphyto(xlsx)
#' phytodata <- read_importphyto(xlsx, download_latest = TRUE)
#' }
read_formphyto <- function(datin){

Expand All @@ -29,22 +29,22 @@ read_formphyto <- function(datin){

# format
out <- datin %>%
dplyr::select(epchc_station = StationNumber, Date = SampleTime, phylum = PHYLUM, name = NAME, count = COUNT, units = Units) %>%
dplyr::select(epchc_station = StationNumber, Date = SampleTime, phylum = PHYLUM, class = CLASS, name = NAME, count = COUNT, units = Units) %>%
dplyr::filter(epchc_station %in% !!stations) %>%
dplyr::mutate(
count = as.numeric(count),
Date = as.Date(Date),
# qrt = quarter(Date, with_year = TRUE),
name = dplyr::case_when(
name %in% c('Pyrodinium bahamense', 'Karenia brevis', 'Tripos hircus', 'Pseudo-nitzschia sp.', 'Pseudo-nitzschia pungens') ~ name,
phylum %in% c('Bacillariophyta', 'Cyanobacteria') ~ phylum,
!is.na(phylum) ~ 'other',
T ~ NA_character_
class %in% c('Bacillariophyceae', 'Coscinodiscophyceae', 'Mediophyceae') ~ 'Diatoms',
phylum %in% 'Cyanobacteriota' ~ 'Cyanobacteria',
T ~ 'other'
)
) %>%
dplyr::filter(!is.na(name)) %>%
dplyr::group_by(epchc_station, Date, name, units) %>%
dplyr::summarise(count = sum(count, na.rm = T)) %>%
dplyr::summarise(count = median(count, na.rm = T)) %>%
dplyr::ungroup() %>%
dplyr::mutate(
yrqrt = lubridate::floor_date(Date, unit = 'quarter'),
Expand Down
4 changes: 2 additions & 2 deletions man/read_formphyto.Rd

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

2 changes: 1 addition & 1 deletion vignettes/intro.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ After the phytoplankton data are successfully imported, you can view them from t
phytodata
```

These data are highly summarized from the raw data file available online. Cell counts (as number of cells per 0.1mL) for selected taxa are summed for each station by quarters (i.e., Jan/Feb/Mar, Apr/May/Jun, etc.). The quarter is indicated in the `yrqrt` column specified by the starting date of each quarter (e.g., `1975-07-01` is the quarter Jul/Aug/Sep for 1975). These data are primarily used to support analyses in the water quality dashboard: <https://shiny.tbep.org/wq-dash/>
These data are highly summarized from the raw data file available online. Cell counts (as number of cells per 0.1mL) for selected taxa are shown by date and quarter (i.e., Jan/Feb/Mar, Apr/May/Jun, etc.) for each station. The quarter is indicated in the `yrqrt` column specified by the starting date of each quarter (e.g., `1975-07-01` is the quarter Jul/Aug/Sep for 1975). These data are primarily used to support analyses in the water quality dashboard: <https://shiny.tbep.org/wq-dash/>

### Retrieving additional water quality data

Expand Down

0 comments on commit 9f7ae44

Please sign in to comment.