Skip to content
Back to formatted view

Raw Message

Message-ID: <0FB00180-17BA-4DB0-9254-BAF8FE69A845@me.com>
Date: 2012-05-18T20:23:52Z
From: Marc Schwartz
Subject: Recoding numeric value
In-Reply-To: <fcacc543-514b-4061-9169-fa56f2ec92a0@d6g2000vbe.googlegroups.com>

On May 18, 2012, at 2:26 PM, Giggles wrote:

> I am a newbie and can't figure out how to recode a numeric value. In
> my data (pharm311), I have a column called "explain" and I need to
> find all the 6's and change it to NA (blank). Could someone help?
> 
> I'm sorry if this is too basic, I started messing with R this week and
> got stuck with this problem since yesterday...
> 
> Thanks in advance!

The easiest and canonical way would be:

  is.na(pharma311$explain) <- pharma311$explain == 6

See ?is.na for more information.

Just to be picky, an NA value is not the same as blank. That is NA != "". R has specific behavior in dealing with NA values.

Regards,

Marc Schwartz