1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 21:22:01 +02:00

(v1.6.0.9014) as.rsi() for numeric values

This commit is contained in:
2021-04-30 13:18:48 +02:00
parent a9fd4aa49f
commit e405de079c
18 changed files with 88 additions and 98 deletions

View File

@ -586,6 +586,8 @@ barplot.rsi <- function(height,
if (length(colours_RSI) == 1) {
colours_RSI <- rep(colours_RSI, 3)
} else {
colours_RSI <- c(colours_RSI[2], colours_RSI[3], colours_RSI[1])
}
main <- gsub(" +", " ", paste0(main, collapse = " "))

View File

@ -259,9 +259,10 @@ as.rsi.default <- function(x, ...) {
}
if (inherits(x, c("integer", "numeric", "double")) && all(x %in% c(1:3, NA))) {
x[x == 1] <- "S"
x[x == 2] <- "I"
x[x == 3] <- "R"
x <- as.character(x) # this is needed to prevent the vctrs pkg to throw an error
x[x == "1"] <- "S"
x[x == "2"] <- "I"
x[x == "3"] <- "R"
} else if (!all(is.na(x)) && !identical(levels(x), c("S", "I", "R")) && !all(x %in% c("R", "S", "I", NA))) {