[6550] in s-news-athena
Re: replace -99 by NA
daemon@ATHENA.MIT.EDU (Martin Maechler)
Thu Mar 2 04:03:58 1995
From: Martin Maechler <maechler@stat.math.ethz.ch>
Date: Thu, 2 Mar 1995 09:48:09 +0100
To: chang@muskie.biostat.umn.edu
Cc: S-news@utstat.toronto.edu, chang@muskie.biostat.umn.edu
In-Reply-To: <9503020040.AA09635@carp.biostat.umn.edu> (chang@muskie.biostat.umn.edu)
Reply-To: Martin Maechler <maechler@stat.math.ethz.ch>
>>>>> "Chang" == Chang Yu <chang@muskie.biostat.umn.edu> writes:
Chang> Hi, Dear all, It is a simple question. I just could not get it.
...........
Chang> In the data file the missing data were coded as -99 and they
Chang> were read into a data frame as -99 by function "read.table".
Chang> Now I want to replace -99 by NA so tree() function will know it,
Chang> otherwise it will work on it as if they are numerical values
Chang> -99. I tried the argument "na.strings=" -99"" without any
Chang> luck. It is the wrong way to do it.
Chang> Could anyone give me a hint?
Yes, why don't you just do
dlsoa.data[ dlsoa.data == -99 ] <- NA
which replaces all -99 numbers by NA's.
In case you also have 'factor's in your data frame you'd need
dlsoa.data[ dlsoa.data == -99 | dlsoa.data == "-99" ] <- NA
Martin Maechler <maechler@stat.math.ethz.ch> <>< _
Seminar fuer Statistik, SOL F5 _| |_
ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND |_ _|
phone: x-41-1-632-3408 fax: ...-1086 |_|