Skip to content
Prev 22535 / 398502 Next

The unary - operator and matrix column labels

Kort, Eric <Eric.Kort at vai.org> writes:
If you know "ig1" is indeed a column of the matrix "data", this should work:

R> data[ , -match(ig1, colnames(data))]

If you don't know that for sure, and/or you want to preserve the matrix
structure of the result (drop=F), then here's a fancier version:

R> data[ , setdiff(colnames(data), ig1), drop=F]