Would be nice if either of these would work
fcase(
iris$Sepal.Length > 5, ">5",
iris$Sepal.Length < 4, "<4",
TRUE, as.character(iris$Sepal.Length)
)
# Results in an error
fcase(
iris$Sepal.Length > 5, ">5",
iris$Sepal.Length < 4, "<4",
default = as.character(iris$Sepal.Length) # Length of 'default' must be 1.
)
My current solution (maybe I am missing some neater solution):
fcase(
iris$Sepal.Length > 5, ">5",
iris$Sepal.Length < 4, "<4",
rep(TRUE, nrow(iris)), as.character(iris$Sepal.Length)
)
dplyr::case_when(
iris$Sepal.Length > 5 ~ ">5",
iris$Sepal.Length < 4 ~ "<4",
TRUE ~ as.character(iris$Sepal.Length)
)
Would be nice if either of these would work
My current solution (maybe I am missing some neater solution):