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

Peter Dalgaard p.dalgaard at biostat.ku.dk
Tue Dec 16 17:31:36 CET 2008


Cliff Behrens wrote:
> 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.

Your example is not reproducible and self-contained. What is 
"permutations" and "coinMat"??

I bet it isn't minimal either.

It doesn't seem to be happening for me with a recent(!) version of R, 
but you could just be misinterpreting the backtick quoting.

-
    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907



More information about the R-help mailing list