Assuming everything is possible in R: would it be possible to make the below
work without breaking existing code?
It would be possible, but not I think desirable.
c(exclude) is fine (works now, does nothing useful except strip
attributes). But -<char vector> will give an error: that's not
necessarily the end, as `[` is a SPECIALSXP and so is passed unevaluated
arguments. However, its first step is method dispatch and that evaluates
all the arguments, so a substantial internal rewrite would be needed.
It would be fairly easy to make
work, and select=-<col_name> already works. I think though that messing
with `[` would be too dangerous, and would also lead to expectations that
all its methods should accept this notation (and hence many would need to
be re-written, including [.data.frame as used here). And then people
would expect this to work on RHS, so [<- would need to be re-written ....
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
# In analogy....
a[-c(exclude),] #invalid argument to unary operator
Brian D. Ripley, rip...@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595