On Oct 13, 2008, at 5:36 AM, Dieter Menne wrote:
Prof Brian Ripley <ripley <at> stats.ox.ac.uk> writes:
Yes: DF[is.na(match(row.names(DF), exclude_me)), ]
Assuming everything is possible in R: would it be possible to make
the below
work without breaking existing code?
a <- data.frame(x=1:10)
rownames(a) = letters[1:10]
exclude = c("a","c")
a[is.na(match(row.names(a), exclude)), ] # not really that easy to
remember
a[-c(1,3),]
# In analogy....
a[-c(exclude),] #invalid argument to unary operator
Given the negative to your question, I wonder if you would find, as I
hope works for me, that it will be easier to remember this
(equivalent) form?
> a[ ! row.names(a) %in% exclude, ]
[1] 2 4 5 6 7 8 9 10
... equivalent because, per the help page, %in% is defined by
function(x,table) {match( x, table , nomatch=0) > 0} and the nomatch
argument "converts" the NA's properly from a logical perspective. The
help page defines a %w/o% function in just such a manner.
--
David Winsemius
Heritage Labs
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.