Skip to content

Commit 43290af

Browse files
committed
fix use of match.arg output and be consistent
1 parent b0904a7 commit 43290af

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

NEWS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Version 2.0.5
2+
-------------
3+
4+
BUG FIXES
5+
6+
* Resolved silent error (no longer silent in R 4.1) from failure to use output
7+
of `match.arg` (#122).
8+
19
Version 2.0.4
210
-------------
311

R/community_diversity.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ community_diversity <- function(df,
6666
metric = c("Shannon", "InverseSimpson")) {
6767

6868
# verify measure choice
69-
measure <- match.arg(metric)
69+
metric <- match.arg(metric)
7070

7171
# check no NAs in abundance column
7272
if (any(is.na(df[[abundance.var]]))) stop("Abundance column contains missing values")
@@ -81,9 +81,9 @@ community_diversity <- function(df,
8181
}
8282

8383
# get function for chosen measure, and calculate output
84-
diversity <- get(measure)
84+
diversity <- get(metric)
8585
comdiv <- aggregate.data.frame(df[abundance.var], df[by], FUN = diversity)
86-
names(comdiv) <- c(by, measure)
86+
names(comdiv) <- c(by, metric)
8787

8888
return(comdiv)
8989
}

R/community_structure.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ community_structure <- function(df,
7171
metric = c("Evar", "SimpsonEvenness", "EQ")) {
7272

7373
# verify measure choice
74-
measure <- match.arg(metric)
74+
metric <- match.arg(metric)
7575

7676
# check no NAs in abundance column
7777
if(any(is.na(df[[abundance.var]]))) stop("Abundance column contains missing values")
@@ -95,7 +95,7 @@ community_structure <- function(df,
9595
warning("Evenness values contain NAs because there are plots with only one species")
9696
}
9797

98-
names(comstruct) <- c(by, 'richness', measure)
98+
names(comstruct) <- c(by, 'richness', metric)
9999

100100
return(comstruct)
101101
}

R/synchrony.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ synchrony <- function(df, time.var,
106106
# @return output The degree of species synchrony. If "Loreau", 1 is perfect synchrony and 0 is perfect asynchrony.
107107
# If "Gross", 1 is perfect synchrony and -1 is perfect asynchrony.
108108
synch_onerep <- function(df, time.var, species.var, abundance.var,
109-
metric = "Loreau") {
110-
metric = match.arg(metric, choices = c("Loreau", "Gross")) # for partial argument matching
109+
metric = c("Loreau", "Gross")) {
110+
metric = match.arg(metric) # for partial argument matching
111111

112112
#remove any species that were never present.
113113
df <- subset(df, abundance.var > 0)

0 commit comments

Comments
 (0)