On Fri, 30 Sep 2005, "Jens Oehlschlägel" wrote:
Dear all,
The following shows cases where accessing elements via their name fails (if
the
name is a string of length zero).
This looks deliberate (there is a function NonNullStringMatch that does
the matching). I assume this is because there is no other way to
indicate that an element has no name.
If so, it is a documentation bug -- help(names) and FAQ 7.14 should
specify this behaviour. Too late for 2.2.0, unfortunately.
-thomas
Best regards
Jens Oehlschlägel
p <- 1:3
names(p) <- c("a","", as.character(NA))
p
a <NA>
1 2 3
for (i in names(p))
+ print(p[[i]])
[1] 1
[1] 2
[1] 3
# error 1: vector subsripting with "" fails in second element
for (i in names(p))
+ print(p[i])
a
1
<NA>
NA
<NA>
3
# error 2: print method for list shows no name for second element
p <- as.list(p)
for (i in names(p))
+ print(p[[i]])
[1] 1
[1] 2
[1] 3
# error 3: list subsripting with "" fails in second element
for (i in names(p))
+ print(p[i])
$a
[1] 1
$"NA"
NULL
$"NA"
[1] 3
version
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 2
minor 1.1
year 2005
month 06
day 20
language R
# -- replication code ----------------------------------
p <- 1:3
names(p) <- c("a","", as.character(NA))
p
for (i in names(p))
print(p[[i]])
# error 1: vector subsripting with "" fails in second element
for (i in names(p))
print(p[i])
# error 2: print method for list shows no name for second element
p <- as.list(p)
for (i in names(p))
print(p[[i]])
# error 3: list subsripting with "" fails in second element
for (i in names(p))
print(p[i])
--
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Thomas Lumley Assoc. Professor, Biostatistics
[EMAIL PROTECTED] University of Washington, Seattle
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel