Message-ID: <4B03D9EE.2080407@uclouvain.be>
Date: 2009-11-18T11:26:38Z
From: Alain Guillet
Subject: Switch Help
In-Reply-To: <7f3f57470911180239s2ac40b6ey121feb1c3ba59bfa@mail.gmail.com>
I believe that is what you want:
aar <-function(command) {
for(i in command){
cat(i,":",switch(EXPR=i,
scrn = "Screening",
dx = "Diagnosis",
df = "Don't Forget"),
"\n")
}
}
> aar(c("dx","df"))
dx : Diagnosis
df : Don't Forget
Alain
oscar linares wrote:
> Dear Rexperts,
>
> Given,
>
> aar <-function(command) {
>
> switch(command,
> {scrn = cat("scrn :Screening","\n")}
> {dx = cat("dx :Diagnosis","\n")}
> {df = cat("df :Don't Forget","\n")}
> )
> }
>
> I want to be able to do:
>
> aar("dx") # function does cat("dx :Diagnosis","\n")
>
> aar(c("dx","df")) # function does cat("dx :Diagnosis","\n")
> # function does df = cat("df :Don't
> Forget","\n")
>
> BUT IT IS NOT WORKING FOR ME.
>
> Please help:-)
>
>
--
Alain Guillet
Statistician and Computer Scientist
SMCS - Institut de statistique - Universit? catholique de Louvain
Bureau c.316
Voie du Roman Pays, 20
B-1348 Louvain-la-Neuve
Belgium
tel: +32 10 47 30 50