[R] Set a Numeric Field To Blank

David Winsemius dwinsemius at comcast.net
Tue Feb 8 17:52:25 CET 2011


On Feb 8, 2011, at 11:40 AM, Sparks, John James wrote:

> Hi,
>
> I have one of those questions that I suspect is very simple, but  
> hard to
> classify, so I have been searching for quite some time and am not  
> able to
> find it.
>
> If I have a data frame and I want to change all the values of one of  
> the
> columns to blanks, what is the syntax?  I tried a few different  
> spellings
> of Null,

Null wouldn't work. (It's not a name or value known to the  
interpreter.) Setting to  NULL would have removed the whole column.
> etc., but can't get it.  Can someone please send me what I
> suspect is a one line solution to this?

A blank is "".  Missing is NA

If you want a blank:  dfrm$colnm <- ""

If you want missing: is.na(dfrm$colnm) <- TRUE

>
> Many thanks,
> --John J. Sparks, Ph.D.
>
> ______________________________________________
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list