Cliff Behrens wrote:
Peter,

I've inserted response inline below:

Cliff

Peter Dalgaard wrote:
Cliff Behrens wrote:
Peter,

OK...here is reproducible, self-contained code:

library(gregmisc)

Relying on a 3rd party package is not kosher either... Whatever did
list("NA"=2)  or l <- list(2); names(l) <- "NA" do to you?

I'm not sure what you mean by "3rd party?" I downloaded this package from the CRAN site where I get all others. I don't understand your question.

3rd party means that you didn't write it and neither did I/we. You are requesting people to help you, yet expecting that they go out of their way to install a package first. (As it happens, I really don't have gregmisc on this machine.) You could easily have created an example of a list with "NA" as a name, but that would of course have been work for you rather than for people on the list.



columnNames <- c("A","B","C","D","N","a","b","c")
namePerms<- permutations(length(columnNames),2,columnNames,repeats=TRUE)
nameList <- paste(namePerms[,1],namePerms[,2],sep="")
dataList <- lapply(1:length(nameList), function(level) {})
names(dataList)<- nameList ## The "NA" is interpreted that the name is missing for one list in dataList

If you inspect the contents of dataList, you will find the following showing that the name "NA" is treated differently:

Anyways....  As I thought:

Remember that NA is a reserved word. You get the same kind of reaction if you name an element "for" or "in". It denotes that you need to quote the name for indexing with $:

I thought that since all of the names in namesList were type char, there was no need to enclose these in quotation marks.

That's not the point. It works fine, it is just that the output is showing you how to access the element afterwards.

> names(l) <- "NA"
> l$NA
Error: unexpected numeric constant in "l$NA"
> l$`NA`
[1] 2
> l$"NA"
[1] 2
> l[["NA"]]
[1] 2
> names(l)
[1] "NA"

......




--
   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
~~~~~~~~~~ - ([email protected])              FAX: (+45) 35327907

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to