Skip to content

Commit

Permalink
fixes #5 (hydrophytes should be NA when wetland indicators are not li…
Browse files Browse the repository at this point in the history
…sted in regional db)
  • Loading branch information
ifoxfoot committed Aug 24, 2023
1 parent e39d4df commit 2be2268
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
26 changes: 15 additions & 11 deletions R/cover_metrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,21 @@ transect_summary <- function(x, key = "name", db, cover_class = "percent_cover",
# Native Mean Wetness
mean(dplyr::filter(unique_entries, .data$nativity == "native")$w, na.rm = TRUE),
#% hydrophytes
if(db %in% c("dakotas_excluding_black_hills_2017",
"delaware_2013",
"illinois_2020",
"iowa_2001","louisiana_coastal_prairie_2006",
"mid_atlantic_allegheny_plateau_glaciated_2012",
"mid_atlantic_allegheny_plateau_nonglaciated_2012",
"mid_atlantic_ridge_valley_2012",
"minnesota_wetlands_2007",
"pennsylvania_piedmont_2013")) {
(sum(entries$w < -1, na.rm = TRUE )/length(entries$w))*100
} else {(sum(entries$w < 0, na.rm = TRUE )/length(entries$w))*100}
if (all(is.na(entries$w))) {
NA
} else {
if(db %in% c("dakotas_excluding_black_hills_2017",
"delaware_2013",
"illinois_2020",
"iowa_2001","louisiana_coastal_prairie_2006",
"mid_atlantic_allegheny_plateau_glaciated_2012",
"mid_atlantic_allegheny_plateau_nonglaciated_2012",
"mid_atlantic_ridge_valley_2012",
"minnesota_wetlands_2007",
"pennsylvania_piedmont_2013")) {
(sum(entries$w < -1, na.rm = TRUE )/length(entries$w))*100
} else {(sum(entries$w < 0, na.rm = TRUE )/length(entries$w))*100}
}
)

#bind metrics and values into data frame
Expand Down
17 changes: 10 additions & 7 deletions R/fqi_metrics.R
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,16 @@ all_metrics <- function(x, key = "name", db, allow_no_c = TRUE) {
# Native Mean Wetness
mean(dplyr::filter(entries, .data$nativity == "native")$w, na.rm = TRUE),
#% hydrophytes
if(db %in% c("dakotas_excluding_black_hills_2017", "delaware_2013", "illinois_2020",
"iowa_2001","louisiana_coastal_prairie_2006", "mid_atlantic_allegheny_plateau_glaciated_2012",
"mid_atlantic_allegheny_plateau_nonglaciated_2012", "mid_atlantic_ridge_valley_2012",
"minnesota_wetlands_2007", "pennsylvania_piedmont_2013")) {
(sum(entries$w < -1, na.rm = TRUE)/length(entries$w))*100
} else {(sum(entries$w < 0, na.rm = TRUE)/length(entries$w))*100}

if (all(is.na(entries$w))) {
NA
} else {
if(db %in% c("dakotas_excluding_black_hills_2017", "delaware_2013", "illinois_2020",
"iowa_2001","louisiana_coastal_prairie_2006", "mid_atlantic_allegheny_plateau_glaciated_2012",
"mid_atlantic_allegheny_plateau_nonglaciated_2012", "mid_atlantic_ridge_valley_2012",
"minnesota_wetlands_2007", "pennsylvania_piedmont_2013")) {
(sum(entries$w < -1, na.rm = TRUE)/length(entries$w))*100
} else {(sum(entries$w < 0, na.rm = TRUE)/length(entries$w))*100}
}
)

#bind metrics and values into data frame
Expand Down

0 comments on commit 2be2268

Please sign in to comment.