Re: [R] Switch Help

2009-11-18 Thread oscar linares
t;, > "df" > > > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of oscar linares > Sent: 18 November 2009 10:40 > To: r-help@r-project.org > Subject: [R] Switch Help > > Dear Rexperts, >

Re: [R] Switch Help

2009-11-18 Thread Alain Guillet
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

Re: [R] Switch Help

2009-11-18 Thread Colin Millar
quot; -Original Message----- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of oscar linares Sent: 18 November 2009 10:40 To: r-help@r-project.org Subject: [R] Switch Help Dear Rexperts, Given, aar <-function(command) { switch(command, {scrn

Re: [R] Switch Help

2009-11-18 Thread Henrique Dallazuanna
If you want type twice commands in function aar, you could try this: aar <-function(command) { switch(command, scrn = cat("scrn :Screening","\n"), dx = cat("dx:Diagnosis","\n"), df = cat("df:Don't Forget","\n")) } invisible(Vectorize(aar)(c('dx', 'df'))

Re: [R] Switch Help

2009-11-18 Thread Colin Millar
n match.arg(command) : 'arg' should be one of "scrn", "dx", "df" -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of oscar linares Sent: 18 November 2009 10:40 To: r-help@r-project.org Subject: [R] Switch He

[R] Switch Help

2009-11-18 Thread oscar linares
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")) # f