[R] looking for the na.omit equivalent for a matrix of characters

Bill.Venables at csiro.au Bill.Venables at csiro.au
Tue May 29 05:57:47 CEST 2007

Surely all you need to do is change them to missing and use na.omit.

x <- matrix(letters, 13, 2)
x[4] <- "NA"  # put one in the middle

is.na(x[x == "NA"]) <- TRUE
(x <- na.omit(x))

Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile:                (I don't have one!)
Home Phone:                     +61 7 3286 7700
mailto:Bill.Venables at csiro.au

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Andrew Yee
Sent: Tuesday, 29 May 2007 12:50 PM
To: r-help at stat.math.ethz.ch
Subject: [R] looking for the na.omit equivalent for a matrix of

I have a matrix of characters (actually numbers that have been read in
numbers), and I'd like to remove the NA.

I'm familiar with na.omit, but is there an equivalent of na.omit when
the NA
are the actual characters "NA"?


	[[alternative HTML version deleted]]

R-help at stat.math.ethz.ch mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list