Re: [R] Extracting column name in apply/lapply

2006-08-28 Thread Gabor Grothendieck
This can be done using a similar style but without a loop by using sapply over the indexes rather than over the columns: sapply(1:ncol(X), f) f <- function(i) {...whatever...} ...whatever... can now refer to colnames(X)[i] and X[,i] On 8/28/06, Sundar Dorai-Raj <[EMAIL PROTECTED]> wrote: > > > N

Re: [R] Extracting column name in apply/lapply

2006-08-28 Thread Sundar Dorai-Raj
Nick Desilsky wrote: > Hi, > > any good trick to get the column names for title() aside from running > lapply on the column indexes? > > Thanks > > Nick. > > apply(X[,numCols],2,function(x){ > nunqs <- length(unique(x)) > nnans <- sum(is.na(x)) > info <- paste("un

[R] Extracting column name in apply/lapply

2006-08-28 Thread Nick Desilsky
Hi, any good trick to get the column names for title() aside from running lapply on the column indexes? Thanks Nick. apply(X[,numCols],2,function(x){ nunqs <- length(unique(x)) nnans <- sum(is.na(x)) info <- paste("uniques:",nunqs,"(",nunqs/n,")","NAs:",nnans,"(",nn