[R] names( d$columnname )

ivo welch ivowel at gmail.com
Mon Apr 23 04:36:25 CEST 2007

yes, this was what I was asking for.  I had the notion that one could
tag almost anything with a name, and did not appreciate the scope for
confusion.  thank you for the explanation.  regards, /ivo

On 4/22/07, Duncan Murdoch <murdoch at stats.uwo.ca> wrote:
> On 4/22/2007 5:46 PM, ivo welch wrote:
> > dear R wizards --- would it make sense for names(d$columnname) to be
> > "columnname"?  I can preserve the columnname through x=subset(dataset,
> > select="columnname"), of course, but it would seem that x=d$columnname
> >  could also do this.  No?  Sincerely,  /iaw
> If I understand what you're asking, I don't think so.
> d$columnname
> extracts an element of the list d.  It's typically some sort of vector,
> and vectors don't know what their own name is.
> names(d$columnname)
> looks for a names attribute on that vector.  If it doesn't have one,
> you'll get NULL.
> There are plenty of functions in R which depend on the form of the
> argument passed to them, not just its value, but we shouldn't add more
> without a very good reason.  The change you ask for would mess up the
> following calculation:
>  > x <- 1:26
>  > names(x) <- letters
>  > d <- list(columnname=x)
>  > names(d$columnname)
>   [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p"
> "q" "r"
> [19] "s" "t" "u" "v" "w" "x" "y" "z"
> Duncan Murdoch

More information about the R-help mailing list