Switch Help
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