[R] How to replace NAs in a vector of factors?
Rolf Turner
r.turner at auckland.ac.nz
Wed Jul 22 03:38:40 CEST 2009
On 22/07/2009, at 1:21 PM, jim holtman wrote:
> Notice that three items are returned where you thought one was:
>
> [1] FALSE TRUE TRUE TRUE FALSE
>> db1$olditems[db1$olditems==''] #wait, only one item is returned?
> [1]
> Levels: nuts soup
>> db1[db1$olditems=='',] #somehow this works!
> olditems prices
> 2 3.25
> 3 4.42
> 4 2.25
>> paste('[',db1$olditems[db1$olditems==''],']') # put some
>> characters around return values
> [1] "[ ]" "[ ]" "[ ]"
>>
>
>
> The '[1]' was just an indication that this is the first value returned
> and the other two were blanks so you did not see them. Also "" is
> just that; a blank and not NA.
Strictly speaking --- or maybe even not so strictly --- a ***null
character***,
not a blank. "" != " "
cheers,
Rolf Turner
<snip>
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
More information about the R-help
mailing list