@@ -55,18 +55,9 @@ sppMatch <- function(species, match = c("LandR", "Latin_full", "EN_generic_short
5555 " column(s) not found in sppEquiv: " ,
5656 paste(shQuote(c(match , return )[! colExists ]), collapse = " , " ))
5757
58+ # Allow duplicate matches if there is a single unique set of return values
5859 if (! is.null(return )){
59-
60- # Allow duplicate matches if there is a single unique set of return rows
61- # # Create secondary matches from duplicated rows
62- sppEquivUQ <- sppEquiv [, lapply(.SD , function (x ) list (list (x ))), by = return ]
63-
64- sppEquiv <- sppEquivUQ [, .SD , .SDcols = c(match , return )]
65- sppExtras <- sppEquivUQ [, .SD , .SDcols = setdiff(names(sppEquiv ), c(match , return ))]
66- if (ncol(sppExtras ) == 0 ) sppExtras <- NULL
67-
68- }else {
69- sppExtras <- NULL
60+ sppEquiv <- unique(sppEquiv [, .SD , .SDcols = unique(c(match , return ))])
7061 }
7162
7263 # Set function for matching character columns
@@ -113,7 +104,6 @@ sppMatch <- function(species, match = c("LandR", "Latin_full", "EN_generic_short
113104 inputs = speciesUQ ,
114105 choices = choices ,
115106 choiceTable = sppEquiv ,
116- choiceTableExtra = sppExtras ,
117107 identical = TRUE ,
118108 funSimplify = .chSimple ,
119109 nearMatches = nearMatches ,
0 commit comments