[R] Zero is not zero
Duncan Murdoch
dmurdoch at pair.com
Wed May 28 21:02:25 CEST 2003
On Wed, 28 May 2003 10:48:08 -0400, you wrote:
>Hello, There:
>I read data from tab-delimted text file(1888.txt) in C:/temp, which has
>thousands rows and 80 colulms, using read.delim("C:/temp/1888.txt"). when I
>retrieved the numeric coulum which has real zero values and applies R buid-in
>function such as mean( ), sum() and got a result of NA. It seems that R (R
>1.6.2 in windows) considers zero as missing value (NA). Thus my question is
>how to read the real zero as zero.
No, read.delim doesn't treat "0" as missing. What is likely happening
is that some line of your file has a typo or other error in it, so it
doesn't look like a number, and the whole column is converted to
character mode.
To find where the error is, try as.numeric(x), where x is the column
containing your data, and it'll convert all the strings that don't
look like numbers to NA.
Duncan Murdoch
More information about the R-help
mailing list