[R] Problem assigning "NA" as a level name in a list

Cliff Behrens cliff at research.telcordia.com
Tue Dec 16 17:12:01 CET 2008


I want to generate a list (called "dataList" below) where each of its 
levels is named.  These names are assigned to nameList, which contains 
all possible permutations of size two taking letters from a larger 
alphabet, e.g., "aa",...,"Fd",..,"Z1",...  One of these permutations is 
the character string "NA".  It seems that when I try to name one of the 
dataList levels "NA", using names(dataList)<- nameList, the names() 
function assigns the missing character to the level.  Is there someway 
to preserve "NA" as the name of a level in dataList?  Here is the R code 
I have been using to do this.

namePerms<- permutations(ncol(coinMat),2,colnames(coinMat),repeats=TRUE)
nameList <- paste(namePerms[,1],namePerms[,2],sep="")
dataList <- lapply(1:length(nameList), function(level) {})
names(dataList)<-  nameList     ## The "NA" in nameList is interpreted 
so that the name "NA" is missing for one level in dataList

I am running R 2.4.1 in the Windows XP environment.

Thanks for any help that can be offerred.

Cliff Behrens




More information about the R-help mailing list