Closed hadley closed 9 years ago
Something like this:
check_scale <- function(x) { if (is.numeric(x) && length(x) == 1) { if (x %in% c(110, 50, 10)) return(x) } else if (is.character(x) && length(x) == 1) { x <- c(small = 110, medium = 50, large = 10)[tolower(x)] if (!is.na(x)) return(unname(x)) } stop("Invalid `scale`. Must be [110, 50, 10, 'small', 'medium', 'large']", call. = FALSE) } check_scale(110) check_scale("small")
I personal don't think you need to allow "110" as a valid input
done 33229f148f7ed9d0316fca97004861b0f6f70f45
Something like this:
I personal don't think you need to allow "110" as a valid input