[R] numeric coercion when one or more elements is non numerice
Arthur Steinmetz
apsteinmetz at yahoo.com
Wed Jan 30 16:53:19 CET 2008
I don't understand this behavior. Why does the every data point get trashed by data.matrix when there is one non-numeric element in the array? Thanks.
> temp
GDP CPIYOY
19540 2098.1 garbage
19632 2085.4 0.9
19724 2052.5 0.8
19814 2042.4 1.1
> data.matrix(temp)
GDP CPIYOY
19540 4 4
19632 3 2
19724 2 1
19814 1 3
>
I'd like garbage to become NA but I tried filtering the array to scrub the data but it has no effect. This illustrates it:
> temp[1,2] <- NA
> temp
GDP CPIYOY
19540 2098.1 <NA>
19632 2085.4 0.9
19724 2052.5 0.8
19814 2042.4 1.1
> data.matrix(temp)
GDP CPIYOY
19540 4 NA
19632 3 2
19724 2 1
19814 1 3
>
-- Art Steinmetz
____________________________________________________________________________________
Be a better friend, newshound, and
More information about the R-help
mailing list