[r] Case Statement Equivalent in R