Re: [R] simplify this instruction

From: Wacek Kusnierczyk <Waclaw.Marcin.Kusnierczyk_at_idi.ntnu.no>
Date: Thu, 20 Nov 2008 10:08:23 +0100

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



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 20 Nov 2008 - 09:10:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 20 Nov 2008 - 09:30:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive