Skip to content

Commit

Permalink
varible definition fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
andybeet committed Feb 23, 2022
1 parent 863d8a0 commit b0387d6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
^assessmentdata\.Rproj$
^stocksmart\.Rproj$
^\.Rproj\.user$

#folders
Expand Down
6 changes: 2 additions & 4 deletions R/get_latest_metrics.r
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#' Filter most recent time series data
#'
#' ### INCOMPLETE ###
#'
#' Pulls the most recent data for set of metrics provided.
#' Often a benchmark or a Full update contains the longest time series of data
#' whereas partial updates only contain data since last benchmark.
Expand Down Expand Up @@ -46,15 +44,15 @@ get_latest_metrics <- function(itis=NULL, metrics = c("Catch","Abundance")) {
# find assessment years in which all selected metrics are reported. then select the most recent year
# and join the last year, first year to the df
stats <- allStats %>%
dplyr::filter(Metric %in% metrics) %>%
dplyr::filter(.data$Metric %in% metrics) %>%
dplyr::group_by(.data$StockName,.data$CommonName,.data$StockArea,.data$ITIS,
.data$AssessmentYear) %>%
dplyr::summarise(sumMetric = dplyr::n(),.groups="drop") %>%
dplyr::filter(.data$sumMetric == length(metrics)) %>%
dplyr::filter(.data$AssessmentYear == max(.data$AssessmentYear)) %>%
dplyr::left_join(.,allStats,by = c("StockName","ITIS","CommonName","StockArea","AssessmentYear")) %>%
dplyr::select(-.data$sumMetric) %>%
dplyr::filter(Metric %in% metrics)
dplyr::filter(.data$Metric %in% metrics)

# select the full time series for the most recent assessments that have all 4 metrics reported
data <- stats %>%
Expand Down
4 changes: 0 additions & 4 deletions man/get_latest_metrics.Rd

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

0 comments on commit b0387d6

Please sign in to comment.