[R] The unary - operator and matrix column labels

Kort, Eric Eric.Kort at vai.org
Thu Aug 8 18:31:15 CEST 2002


I am making some changes to the permax library (so that it will accept NA's).  This function performs a permutation analysis to identify discriminating attributes distinguishing two groups of observations.  It takes the form (at its most simplistic):

permax(data, ig1)

where ig1 is one group of interest.  The other group (if not specified) is assumed to be the remaining observations, namely, -ig1.

The problem is that I would like to be able to specify ig1 not as a vector of numeric indicies, but as a vector of column labels (as specified by data <- as.matrix(read.table("file", header=T....)).  But if I do this:

ig1 <- c('patient1', 'patient2')

then, while I can do this:

data[,ig1]

I can no longer do this:

data[,-ig1]

because the unary operator does not like working with column labels.  Is there a way to go backwards and determine the column indices from the column labels, or perhaps and even more simple way to obtain a vector of complementary column labels given a subset of labels?

Thanks,
Eric



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list