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,
>
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
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
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'))
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
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
6 matches
Mail list logo