I got answer to my question from a previous posting on this forum.
Thank you,
Ashraf
-
[[alternative HTML version deleted]]
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read
Check out
?na.omit
?complete.cases
On 3/21/06, Ashraf Chaudhary <[EMAIL PROTECTED]> wrote:
> Dear Colleagues:
>
> I have a question that is probably too simple but I could not get it.
>
> How to remove all the rows of a data table with missing values?
>
> Let us say my data table is
>
> 1 2 4
Dear Colleagues:
I have a question that is probably too simple but I could not get it.
How to remove all the rows of a data table with missing values?
Let us say my data table is
1 2 4
3 . 5
2 7 .
6 7 8
The result should be,
1 2 4
6 7 8
Thank you,
Ashraf
---
My answers are going to be very similar but with minor cosmetic changes
that hopefully will make it bit more clearer.
1) How do you read in the data ? If you are using read.table (or
read.csv, read.delim, etc) you can set na.strings="-999" to take
advantage of the R's missing value features.
2)
Quoting mark salsburg <[EMAIL PROTECTED]>:
> I am trying to find out if R can recognize specific criteria for removing
> rows (i.e. a prexisting function)
>
> I have a matrix myMatrix that is 12000 by 20
>
> I would like to remove rows from myMatrix that have:
>
> -999 across all columns
> -999 ac
See ?complete.cases and perhaps ?na.omit. You can index the matrix by the
output of complete.cases() for the first case, and feed the matrix without
the omitted column to complete.cases() for the others.
Andy
From: mark salsburg
>
> I am trying to find out if R can recognize specific criteria
I am trying to find out if R can recognize specific criteria for removing
rows (i.e. a prexisting function)
I have a matrix myMatrix that is 12000 by 20
I would like to remove rows from myMatrix that have:
-999 across all columns
-999 across all columns but one
-999 across all columns but two
-9