Skip to content
Prev 47309 / 63424 Next

substring() and propagation of names

Hi,

In R < 3.0.0, we used to get:

   > substring(c(A="abcdefghij", B="123456789"), 2, 6:2)
         A       B       A       B       A
   "bcdef"  "2345"   "bcd"    "23"     "b"

But in R >= 3.0.0, we get:

   > substring(c(A="abcdefghij", B="123456789"), 2, 6:2)
   [1] "bcdef" "2345"  "bcd"   "23"    "b"

The names are not propagated anymore.

Is this an intended change or a bug? I can't find anything about
this in the NEWS file. The man page for substring() in R >= 3.0.0
still states:

   Value:

      ...

      For ?substring?, a character vector of length the longest of the
      arguments.  This will have names taken from ?x? (if it has any
      after coercion, repeated as needed), and other attributes copied
      from ?x? if it is the longest of the arguments).

Also note that the first argument of substring() is 'text' not 'x'.

Thanks,
H.