A list without names returns NULL for its names:
> names(list(1,2,3)) NULL
but add one named thing, and suddenly the names have a list length:
> names(list(1,2,3,a=4)) [1] "" "" "" "a"
because now it's a named list. I would like the function, according to rnames, to make any list in the list of names, for example:
rnames(list(1,2,3)) == c("","","") identical(rnames(list()), character(0)) length(rnames(foo)) == length(foo) # for all foo
and the following, which is the same name ():
rnames(list(1,2,3,a=3)) == c("","","","a") rnames(list(a=1,b=1)) == c("a","b")
My current hacker method is to add a named case to the list, get the names, and then disable it:
rnames = function(l){names(c(monkey=1,l))[-1]}
but is there a better / right way to do this?