Re: [R] looking for alternative of 'if-else'

From: Duncan Murdoch <>
Date: Sun, 06 Jul 2008 06:03:30 -0400

On 06/07/2008 4:59 AM, Arun Kumar Saha wrote:
> There is "if-else" loop if I have to choose 1 item from a 2-item list.
> However if I have a list of 4 items (let say) then how i can choose a single
> item without employing 'if-else' loop? I mean in VBA I can use
> "select-case", is there any equivalent in R as well?

See ?switch.

Duncan Murdoch mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sun 06 Jul 2008 - 10:19:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 06 Jul 2008 - 13:31:13 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive