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 across all columns but one
> -999 across all columns but two
> -999 across all columns but three
> -999 across all columns but four
> -999 across all columns but five
>
> (-999 here is my missing value)
>
> Does R have a function for this, I've explored subset() so far
>
You can create a vector that records the number of missing values
in each row
n.notmissing <- apply(myMatrix != -999, 1, sum)
then use row subsetting to remove the ones you don't want
myMatrix[n.notmissing == n, ]
for n = 0, 1, ... 5, etc.
(As an aside, R functions will work better with your data if you use NA
instead of a numeric code to represent missing data.)
Martyn
-----------------------------------------------------------------------
This message and its attachments are strictly confidential. ...{{dropped}}
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html