diff --git a/R/compute_concentrations.R b/R/compute_concentrations.R index cdc62e9..20047cd 100644 --- a/R/compute_concentrations.R +++ b/R/compute_concentrations.R @@ -1,7 +1,8 @@ #' Compute count conversions #' #' @description -#' __ADD DESCRIPTION__ +#' Functions to convert species counts between different formats: raw abundance, +#' relative abundance, and number concentration, using counts metadata. #' #' @param data a `data.frame`. One obtained by `read_*_data()` functions. #' @@ -13,9 +14,11 @@ #' #' @details #' -#' - `compute_concentrations()` __ADD A FEW WORDS__ -#' - `compute_frequencies()` __ADD A FEW WORDS__ -#' - `compute_abundances()` __ADD A FEW WORDS__ +#' - `compute_concentrations()` converts all counts to number concentrations (n specimens/m³). +#' +#' - `compute_frequencies()` converts all counts to relative abundances (% specimens per sampling unit). +#' +#' - `compute_abundances()` converts all counts to raw abundances (n specimens/sampling unit). #' #' @name computations NULL diff --git a/R/plot_record_by_depth.R b/R/plot_record_by_depth.R index 848dd3f..765553d 100644 --- a/R/plot_record_by_depth.R +++ b/R/plot_record_by_depth.R @@ -44,18 +44,27 @@ plot_record_by_depth <- function(data) { data <- data %>% select(.data$sample_id, .data$sample_min_depth, .data$sample_max_depth) %>% - unite('sampling_interval', c(.data$sample_min_depth, - .data$sample_max_depth), sep = '-', - remove = TRUE) %>% + mutate(sampling_interval = ifelse( + .data$sample_min_depth == 0 | (.data$sample_min_depth <= 100 & .data$sample_max_depth <= 100), + 'Surface - 100m', + ifelse(.data$sample_min_depth >= 100 & .data$sample_max_depth <= 300, '100m-300m', + ifelse(.data$sample_min_depth >= 300 & .data$sample_max_depth <= 500, '300m-500m', + ifelse(.data$sample_min_depth >= 500, 'Below 500m', 'Unknown'))))) %>% + select(-c(.data$sample_min_depth, .data$sample_max_depth)) %>% distinct() %>% group_by(.data$sampling_interval) %>% count() %>% - ungroup() %>% - mutate(upper_lim = as.numeric(gsub("-.*", "", .data$sampling_interval))) + ungroup() + data$"sampling_interval" <- factor(data$"sampling_interval", + levels = c('Unknown', + 'Below 500m', + '300m-500m', + '100m-300m', + 'Surface - 100m')) + ggplot(data, - aes(stats::reorder(.data$sampling_interval, -.data$upper_lim), - .data$n)) + + aes(.data$sampling_interval, .data$n)) + geom_col(width = 0.7, col = "black") + xlab("Sampling interval") + ylab("Number of FORCIS samples") + diff --git a/man/computations.Rd b/man/computations.Rd index 29ce623..cdb1af1 100644 --- a/man/computations.Rd +++ b/man/computations.Rd @@ -25,12 +25,13 @@ aggregated by \code{sample_id}.} A \code{data.frame}. } \description{ -\strong{ADD DESCRIPTION} +Functions to convert species counts between different formats: raw abundance, +relative abundance, and number concentration, using counts metadata. } \details{ \itemize{ -\item \code{compute_concentrations()} \strong{ADD A FEW WORDS} -\item \code{compute_frequencies()} \strong{ADD A FEW WORDS} -\item \code{compute_abundances()} \strong{ADD A FEW WORDS} +\item \code{compute_concentrations()} converts all counts to number concentrations (n specimens/m³). +\item \code{compute_frequencies()} converts all counts to relative abundances (\% specimens per sampling unit). +\item \code{compute_abundances()} converts all counts to raw abundances (n specimens/sampling unit). } } diff --git a/vignettes/data-visualization.Rmd b/vignettes/data-visualization.Rmd index 036054a..89fc2bb 100644 --- a/vignettes/data-visualization.Rmd +++ b/vignettes/data-visualization.Rmd @@ -166,10 +166,10 @@ plot_record_by_season(net_data) ## `plot_record_by_depth()` -The function `plot_record_by_depth()` plots the number of records (x-axis) by depth (y-axis). +The function `plot_record_by_depth()` plots the number of records (x-axis) by depth intervals (y-axis). -```{r 'plot-record-by-depth', eval=FALSE} +```{r 'plot-record-by-depth'} # Plot number of records by depth ---- plot_record_by_depth(net_data) ```