From rwehrens@sci.kun.nl  Tue Sep 17 22:25:40 2002
From: rwehrens@sci.kun.nl (rwehrens@sci.kun.nl)
Date: Tue, 17 Sep 2002 23:25:40 +0200 (MET DST)
Subject: switch (PR#2033)
Message-ID: <200209172125.XAA01381@pubhealth.ku.dk>

Full_Name: Ron Wehrens
Version: 1.5.0
OS: Linux, Solaris, OSF alpha
Submission from: (NULL) (128.95.17.61)


Consider these two functions:
switchme <- function(type, ...) {
  switch(type,
         E = max(...),
         V = length(...),
         EII = sum(...),
         VII = prod(...),
         -100)
}
switchme2 <- function(type, ...) {
  switch(type,
         V = length(...),
         EII = sum(...),
         VII = prod(...),
         -100)
}
The bottom one does what I expect. The top one only gives one answer,
independent 
of the second argument.
> switchme2("V", 1:4)
[1] 4
> switchme2("X", 1:4)
[1] -100
> switchme2("EII", 1:4)
[1] 10
> switchme("V", 1:4)
[1] 24
> switchme("X", 1:4)
[1] 24
> switchme("EII", 1:4)
[1] 24
 
Is there something special about "E"?

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


switch (PR#2033)
rwehrens@sci.kun.nl