[R] switch with a single character

From: Henrik Andersson <private.henrik_at_gmail.com>
Date: Thu, 06 Mar 2008 12:50:49 +0100


Can anyone explain the results from switch below when a single charachter "E" is entered? It seems to work with letter S or N...

> switch("East",West=1,East=2) # Correct
[1] 2
> switch("E",W=1,E=2) # Not so correct

[1] 1
> switch("E",E=1,W=2) # Even stranger

[1] "E"
> switch("S",N=1,S=-1) # Correct

[1] -1

Kind regards, Henrik

-- 
Henrik Andersson
Tullstorp 2526
28195 Vankiva
Sweden

Tel: +46 451 19149
Mobil: +46 763 406779

______________________________________________
R-help_at_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.
Received on Thu 06 Mar 2008 - 11:53:12 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 Thu 06 Mar 2008 - 16:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive