s-news
[Top] [All Lists]

NA assignment for character vector

To: Splus Users Group <s-news@lists.biostat.wustl.edu>
Subject: NA assignment for character vector
From: Stephen Lake <slake@hsph.harvard.edu>
Date: Tue, 25 Feb 2003 11:48:09 -0500 (EST)
Hi S-users,

Could someone please tell me how I can assign NA's to
character vectors and matrices? The usual element
assignment does not seem to work. Here is an example:

> vec <- letters[1:5]
> vec
[1] "a" "b" "c" "d" "e"
> vec[4] <- NA
> vec
[1] "a" "b" "c" "NA" "e"
> is.na(vec)
[1] F F F F F

If instead of letters[1:5] I assign the numeric vector
1:5, the behavior is as expected, ie the is.na() function
detects a NA at position 4 of the vector.

Any help would be greatly appreciated,
Steve Lake

PS I am using Version 6.0 Release 1 for Sun SPARC, SunOS 5.5



<Prev in Thread] Current Thread [Next in Thread>