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!
Recoding numeric value
5 messages · Giggles, David Winsemius, Marc Schwartz
On May 18, 2012, at 3: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?
is.na(pharm311$explain) <- pharm311$explain==6 And do note: NA is not the same "blank". It is "missing".
I'm sorry if this is too basic, I started messing with R this week and got stuck with this problem since yesterday...
David Winsemius, MD West Hartford, CT
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
Thanks so much! I thought R places NA for missing values. I'll have to read up on it more. Thanks again!
On May 18, 2:23?pm, Marc Schwartz <marc_schwa... at me.com> wrote:
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
______________________________________________ R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Thank you very much!!
On May 18, 2:22?pm, David Winsemius <dwinsem... at comcast.net> wrote:
On May 18, 2012, at 3: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?
is.na(pharm311$explain) <- pharm311$explain==6 And do note: NA is not the same "blank". It is "missing".
I'm sorry if this is too basic, I started messing with R this week and got stuck with this problem since yesterday...
-- David Winsemius, MD West Hartford, CT
______________________________________________ R-h... at r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.