From wdunlap at tibco.com  Sat Sep 19 00:34:32 2009
From: wdunlap at tibco.com (William Dunlap)
Date: Fri, 18 Sep 2009 15:34:32 -0700
Subject: [Rd] what should names(x) be padded with when length(x) is
	increased?
Message-ID: <77EB52C6DD32BA4D87471DCD70C8D70001CE5F9D@NA-PA-VBE03.na.tibco.com>

R version 2.10.0 Under development (unstable) (2009-09-08 r49628)

Here are two somewhat related questions.

First, when we attach a too short names vector to a vector
the names vector is padded with NA's to the length of the
main vector:  E.g.,
   > x<-1:3
   > names(x)<-c("One","Two")
   > str(x)
    Named int [1:3] 1 2 3
    - attr(*, "names")= chr [1:3] "One" "Two" NA
I expected this length mismatch to cause an error, but I am
biassed by my long usage of S and S+.  Is the extension by
padding with NA what is wanted?

Second, if we extend a named vector with length<- the main
vector is padded with NA's but the names are padded with
empty strings.  Should those be NA's?

   > x<-1:3
   > names(x)<-c("One","Two")
   > length(x)<-4
   > str(x)
    Named int [1:4] 1 2 3 NA
    - attr(*, "names")= chr [1:4] "One" "Two" NA ""

The names "" and NA act alike in that subscript by either
returns structure(NA, names=NA_character_), but they
print differently
   > x
    One  Two <NA>
     1    2    3   NA


Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com 



[Rd] what should names(x) be padded with when length(x) is increased?
William Dunlap