Skip to content

Commit

Permalink
20240213 - convert NAs to frequency of zero when endorsing never_occu…
Browse files Browse the repository at this point in the history
…rred and not_occurred_past_year
  • Loading branch information
isaactpetersen committed Feb 14, 2024
1 parent 0f8178e commit 0f2a0f4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/frequencyPerDuration.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ timesPerInterval <- function(num_occurrences = NULL, interval = NULL, duration =
)

interval_occurrences <- ifelse(
((is.na(num_occurrences) | is.na(interval)) & (not_occurred_past_year == 0 | is.na(not_occurred_past_year))) | num_occurrences < 0, NA,
((is.na(num_occurrences) | is.na(interval)) & (not_occurred_past_year == 0 | is.na(not_occurred_past_year))) | (!is.na(num_occurrences) & num_occurrences < 0), NA,
ifelse(
is.na(not_occurred_past_year), num_occurrences * (duration_days / interval_days),
ifelse(
Expand All @@ -123,7 +123,7 @@ timesPerLifetime <- function(num_occurrences = NULL, never_occurred = NULL) {
}

lifetime_occurrences <- ifelse(
(is.na(num_occurrences) & never_occurred == 0) | num_occurrences < 0, NA,
(is.na(num_occurrences) & never_occurred == 0) | (!is.na(num_occurrences) & num_occurrences < 0), NA,
ifelse(
is.na(never_occurred), num_occurrences,
ifelse(never_occurred == 1, 0, num_occurrences)))
Expand Down

0 comments on commit 0f2a0f4

Please sign in to comment.