[Rd] [ subscripting sometimes loses names (PR#8192)
atp@piskorski.com
atp at piskorski.com
Wed Oct 19 21:50:48 CEST 2005
Here is an example of the losing names problem in stock R 2.2.0. Note
that below, only stock R packages are loaded, and then I manually
source in just my dtk.test.brace.names() testing function, nothing
else.
Since the list-of-lists output of dtk.test.brace.names() is very
lengthy, I've manually cut-and-pasted it into a tabular format to save
space and make inspection easier. As you can see, out of its 15 test
cases, stock R 2.2.0 fails 4 of them while the other 12 are Ok.
Too see what these simple subscripting tests actually DO, please refer
to the body of dtk.test.brace.names() from my previous emails above.
R : Copyright 2005, The R Foundation for Statistical Computing
Version 2.2.0 (2005-10-06 r35749)
> search()
[1] ".GlobalEnv" "package:methods" "package:graphics"
[4] "package:grDevices" "package:datasets" "package:utils"
[7] "package:stats" "Autoloads" "package:base"
> dtk.test.brace.names(return.results.p=T ,only="all")
Ok? Actual Result Desired Result
--- ------------------ ------------------
$vec.1
BAD $vec.1[[1]] $vec.1[[2]]
a c <NA> a c no
1 3 NA 1 3 NA
$diag.1
Ok $diag.1[[1]] $diag.1[[2]]
[1] 1 7 13 19 25 [1] 1 7 13 19 25
$diag.2
Ok $diag.2[[1]] $diag.2[[2]]
[1] 1 7 13 19 25 [1] 1 7 13 19 25
$df.a.1
Ok $df.a.1[[1]] $df.a.1[[2]]
a b a b
4 5 4 5
$df.b.1
BAD $df.b.1[[1]] $df.b.1[[2]]
[1] 4 5 a b
4 5
$df.a.2
Ok $df.a.2[[1]] $df.a.2[[2]]
c b a c b a
6 5 4 6 5 4
$df.b.2
BAD $df.b.2[[1]] $df.b.2[[2]]
[1] 6 5 4 c b a
6 5 4
$df.a.3
Ok $df.a.3[[1]] $df.a.3[[2]]
a b a b
3 4 3 4
$df.b.3
BAD $df.b.3[[1]] $df.b.3[[2]]
[1] 3 4 a b
3 4
$df.a.4
Ok $df.a.4[[1]] $df.a.4[[2]]
col1 col2 col1 col2
2 4 2 4
$df.b.4
Ok $df.b.4[[1]] $df.b.4[[2]]
col1 col2 col1 col2
b 2 4 b 2 4
$df.a.5
Ok $df.a.5[[1]] $df.a.5[[2]]
col1 col2 col1 col2
2 4 2 4
$df.b.5
Ok $df.b.5[[1]] $df.b.5[[2]]
$df.b.5[[1]]$col1 $df.b.5[[2]]$col1
[1] 2 [1] 2
$df.b.5[[1]]$col2 $df.b.5[[2]]$col2
[1] 4 [1] 4
$df.a.6
Ok $df.a.6[[1]] $df.a.6[[2]]
col1 col2 col1 col2
b 2 4 b 2 4
$df.b.6
Ok $df.b.6[[1]] $df.b.6[[2]]
col1 col2 col1 col2
b 2 4 b 2 4
--
Andrew Piskorski <atp at piskorski.com>
http://www.piskorski.com/
More information about the R-devel
mailing list