[R] simplify this instruction

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Thu Nov 20 10:08:23 CET 2008


Rolf Turner wrote:
>
> The issue worrying Wacek was presumably the fact that
> the original poster was treating the ``B'' variable as
> being character, rather than numeric.
>
> So (presumably) what he *really* wanted to say was
> (something like)
>
> ifelse(B%in%as.character(0:9),"A","B")

yepp.

>
> Of course this is sheer pedantry.  

thanks, you're so reliable.

> I'm sure the original poster
> was really concerned with a numeric variable and used the quote
> marks around the digits out of confusion over what was required.
> (Some misguided subconscious notion to the effect that to get character
> output you need character input.)

in any case, the version you propose should do the job.

vQ



More information about the R-help mailing list