Hi all, Here I am trying to implement the switch() function to choose value of a variable depending on the value of an input variable : temp1 <- "1" temp1.name <- switch(temp1, 1 == "aa", 2 == "bb", 3 == "cc", 4 == "dd", 5 == "ee") Goal is if "temp1" equals to 1, then value of temp1.name would be "aa". However I am getting following answer : > temp1 <- "1" > temp1.name <- switch(temp1, + 1 == "aa", + 2 == "bb", + 3 == "cc", + 4 == "dd", + 5 == "ee") > temp1.name [1] FALSE
Can anyone please point me where I am doing wrong? Thanks, [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.