mirror of
https://github.com/msberends/AMR.git
synced 2025-07-13 05:21:50 +02:00
small improvement for is.rsi.eligible, more unit tests
This commit is contained in:
6
R/rsi.R
6
R/rsi.R
@ -99,10 +99,14 @@ is.rsi <- function(x) {
|
||||
#' @export
|
||||
#' @importFrom dplyr %>%
|
||||
is.rsi.eligible <- function(x) {
|
||||
distinct_val <- x %>% unique() %>% sort() %>% as.character()
|
||||
# remove all but a-z
|
||||
distinct_val <- x %>% unique() %>% sort() %>% as.character() %>% gsub("(\\W|\\d)+", "", .)
|
||||
# remove NAs and empty values
|
||||
distinct_val <- distinct_val[!is.na(distinct_val) & trimws(distinct_val) != ""]
|
||||
# get RSI class
|
||||
distinct_val_rsi <- as.character(suppressWarnings(as.rsi(distinct_val)))
|
||||
|
||||
# is not empty and identical to new class
|
||||
length(distinct_val) > 0 &
|
||||
identical(distinct_val, distinct_val_rsi)
|
||||
}
|
||||
|
Reference in New Issue
Block a user