[Rd] Subscripting fails if name of element is "" (PR#8161)
"Jens Oehlschlägel"
oehl_list at gmx.de
Fri Sep 30 15:12:40 CEST 2005
Dear all,
I resend this mail because it was blocked: I submitted a bug from the r-bug
webpage and hypatia seems to block mail that is send from a different IP
than that usually associated with the email. Looks like it is currently
impossible to correctly submit bugs from the website. However, here is the
original bug report:
(PR#8161)
Dear all,
The following shows cases where accessing elements via their name fails (if
the
name is a string of length zero).
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])
--
More information about the R-devel
mailing list