You DON'T need to use backticks. switch() is much older than backticks.
Ordinary quotation marks are fine.
> switch(as.character(1), "2"="YES", "1"="NO")
[1] "NO"
On Thu, 8 Sept 2022 at 07:46, akshay kulkarni wrote:
> Dear Bert,
> Thanks...I went through the doc pages but c
Dear Bert,
Thanks...I went through the doc pages but couldn't glean
from that that for numeric options one has to backtick it. I is not given in
the doc page...I actually had hundreds of different choices and so cannot
depend on evaluation by position...Thanks again...I got t
Well, as it states on the Help page, which should always be the first
place to look for, ummm, help:
"If the value of EXPR is not a character string it is coerced to
integer. Note that this also happens for factors, with a warning, as
typically the character level is meant. If the integer is betwe
Dear Andrew,
Its working. Thanks a lot
Yours sincerely,
AKSHAY M KULKARNI
From: Andrew Simmons
Sent: Thursday, September 8, 2022 12:08 AM
To: akshay kulkarni
Cc: R help Mailing list
Subject: Re: [R] inconsistency in switch statement
1 and 2 are not valid identifiers in R, so you need to surround them with
backticks to make them valid, the same as quoting a string:
switch(Stst, `1` = print("NO"), `2` = print("YES"))
On Wed., Sep. 7, 2022, 14:35 akshay kulkarni, wrote:
> Dear members,
> The foll
5 matches
Mail list logo