Skip to content
Prev 19635 / 63424 Next

PR#6614

On Wed, 23 Feb 2006, Peter Dalgaard wrote:

            
That code with match only works if "Species" is actually
a column of iris.  If not, your result depends on whether
you have a data.frame (an error) or a matrix (a column
of NA's).

I found some mail in a 15 year old sent-mail file that suggested
allowing the tag 'except=' on any of the arguments to "[" to
replace/extend the limited negative integer convention.  The idea was
that
    iris[ except=c(10:20), except=c("Petal.Width","Petal.Length")) ]
would return all rows except 10:20 and all columns except
the ones named.
    iris[ except=integer(0), ]
would return all rows of iris, while iris[-integer(0), ] returns
no rows of iris.

This abuses the tag= notation, but the "[" function doesn't
really support the i= and j= tags that some people expect.

This would take care of the problem that subset(data.frame,select=-name)
only lets you omit columns.

The mail had a version of [.data.frame (for Splus 2.1?) that
implemented this, although, if it is to be used it should be
implemented in the most primitive [ code so all methods use it.

----------------------------------------------------------------------------
Bill Dunlap
Insightful Corporation
bill at insightful dot com
360-428-8146

 "All statements in this message represent the opinions of the author and do
 not necessarily reflect Insightful Corporation policy or position."