better pattern detection
This commit is contained in:
@@ -19,6 +19,27 @@ insertRow <- function(existingDF, newrow, r) {
|
||||
return(existingDF)
|
||||
}
|
||||
|
||||
convertLogical0 <- function(var) {
|
||||
if(is.integer(var) && length(var) == 0) {
|
||||
var <- 0
|
||||
}
|
||||
return(var)
|
||||
}
|
||||
|
||||
smartPatternMatch <- function(string, pattern, chars) {
|
||||
if(chars < 5) {
|
||||
found <- agrep(pattern, string, max.distance = list(all = 0), ignore.case = TRUE)
|
||||
}
|
||||
if(chars > 7) {
|
||||
found <- agrep(pattern, string, max.distance = list(all = 2), ignore.case = TRUE)
|
||||
}
|
||||
else {
|
||||
found <- agrep(pattern, string, max.distance = list(all = 1), ignore.case = TRUE)
|
||||
}
|
||||
found <- convertLogical0(found)
|
||||
return(found)
|
||||
}
|
||||
|
||||
## ERROR HANDLING
|
||||
|
||||
# Check for empty API returns (0 or 1 or 2)
|
||||
|
||||
Reference in New Issue
Block a user