Thanks Jorge and Michael "recode" was exactly what I was looking for.
AG<-2.7 VAR<-recode(as.integer(AG),"c(0,5,8,10)=37;c(1,4)=70;c(3,6,9)=90;c(2,7)=112") VAR [1] 112 Great! All the best, Antônio 2011/8/31 Jorge I Velez <jorgeivanve...@gmail.com> > Hi Antonio, > > Take a look at > > require(car) > ?recode > > for an alternative. > > HTH, > Jorge > > > On Wed, Aug 31, 2011 at 1:27 PM, Antonio Silva <> wrote: > >> Hello >> >> I'm translating a Visual Basic routine to R. >> >> Which command in R is similar to "select case" in VB? >> >> See the example: >> >> select case int(AG) >> case 0, 5, 8, 10 >> VAR = 37 >> case 1, 4 >> VAR = 70 >> case 3, 6, 9 >> VAR = 90 >> case 2, 7 >> VAR = 112 >> end select >> >> A chain of "if else" would not be very elegant. Is there another option? >> >> Thanks in advance. Best regards. >> >> Antonio Olinto >> >> [[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. >> > > -- Antônio Olinto Ávila da Silva Biólogo / Oceanógrafo Instituto de Pesca (Fisheries Institute) São Paulo, Brasil [[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.