Test6 <- function(x) { r <- character(length(x))# to contain the result r[L <- x < -2] <- "pretty negative" r[Z <- !L & x < 1] <- "close to zero" r[I <- !L & !Z & x < 3] <- "in [1, 3)" r[x >= 3] <- "large" r }