Skip to content

Commit

Permalink
Merge pull request #117 from trias-project/fix-use-gratia
Browse files Browse the repository at this point in the history
Adapt code to use gratia
  • Loading branch information
damianooldoni authored Apr 18, 2024
2 parents c81ee6f + c8cd625 commit 8c4cf3f
Show file tree
Hide file tree
Showing 5 changed files with 724 additions and 671 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: trias
Title: Process Data for the Project Tracking Invasive Alien Species
(TrIAS)
Version: 2.0.8
Version: 2.1.0
Authors@R: c(
person("Damiano", "Oldoni", email = "[email protected]",
role = c("aut", "cre"), comment = c(ORCID = "0000-0003-3445-7562")),
Expand Down
16 changes: 8 additions & 8 deletions R/apply_decision_rules.R
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ apply_decision_rules <- function(df,
last_occ = max(.data$last_occ)
) %>%
dplyr::mutate(dr_2 = .data$last_occ > .data$median_occ) %>%
dplyr::select(!!rlang::sym(taxonKey), dr_2)
dplyr::select(!!rlang::sym(taxonKey), "dr_2")

# Rule 3: 0 in the last 5 years?
dr_3 <-
Expand All @@ -237,7 +237,7 @@ apply_decision_rules <- function(df,
dplyr::filter(!!rlang::sym(year) > (max(!!rlang::sym(year)) - 5)) %>%
dplyr::tally(!!rlang::sym(y_var)) %>%
dplyr::mutate(dr_3 = n == 0) %>%
dplyr::select(!!rlang::sym(taxonKey), dr_3)
dplyr::select(!!rlang::sym(taxonKey), "dr_3")

# Rule 4: last value (at eval_year) is the maximum ever observed?
dr_4 <-
Expand All @@ -251,7 +251,7 @@ apply_decision_rules <- function(df,
by = taxonKey
) %>%
dplyr::mutate(dr_4 = .data$last_value == .data$max_occ) %>%
dplyr::select(!!rlang::sym(taxonKey), dr_4)
dplyr::select(!!rlang::sym(taxonKey), "dr_4")

# Join all decision rules together
dr_all <-
Expand Down Expand Up @@ -282,11 +282,11 @@ apply_decision_rules <- function(df,
dplyr::select(
!!rlang::sym(taxonKey),
!!rlang::sym(year),
em_status,
dr_1,
dr_2,
dr_3,
dr_4
"em_status",
"dr_1",
"dr_2",
"dr_3",
"dr_4"
) %>%
dplyr::as_tibble()

Expand Down
Loading

0 comments on commit 8c4cf3f

Please sign in to comment.