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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Kort, Eric <Eric.Kort at vai.org> writes:> 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...?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] -- -- David Brahm (brahm at alum.mit.edu) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Maybe Matching Threads
- help with reshape is needed again!
- help for reshape function
- How can you find the optimal number of values to randomly sample to optimize random forest classification without trial and error?
- complex(?) reshaping question
- missing level of a nested factor results in an NA in lm output