[R] obtaining the name of a named list
Uwe Ligges
ligges at statistik.uni-dortmund.de
Sun May 16 16:03:33 CEST 2004
Ned wrote:
> I have a list d, in which the names of each elements are single
> characters, and the actual elements are bit sequences representing those
> characters. If I type d[1], I get the name and the bit sequence. If I
> type d[[1]], I get only the bit sequence.
d[1] returns a list of length 1, while d[[1]] returns only the element.
> What I want is some way to be able to get the name of the element,
> preferably by specifying an index into the array.
>
> e.g.
>
> > d
> A B C
> "00000" "00001" "0001"
>
> I want some way of saying "give me the name for element number 2" and it
> should return B.
names(B)[2]
Uwe Ligges
BTW: If all list elements are character of length 1, why are you not
using a character vector instead?
>
> cheers,
>
> Ned
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list