[Rd] incorrect handling of arrays of list elements (PR#1301)

joehl@web.de joehl@web.de
Thu, 7 Feb 2002 19:13:46 +0100 (MET)



After checking with the prototype I hope the following to justifies a bug-report:

# you find pure replication syntax at the end


> # the prototype allows for the following, which fails in R
> matrix(vector("list", 6), 3, 2)
Error in matrix(vector("list", 6), 3, 2) : 
        Unimplemented feature in copyVector
> 
> # however the desired object seems to be legally in R as we get the same via
> tt <- vector("list", 6)
> dim(tt) <- c(3,2)
> tt
     [,1]   [,2]  
[1,] "NULL" "NULL"
[2,] "NULL" "NULL"
[3,] "NULL" "NULL"
> 
> # preparing to show further problems
> tt[[1,1]] <- letters
> tt
     [,1]           [,2]  
[1,] "Character,26" "NULL"
[2,] "NULL"         "NULL"
[3,] "NULL"         "NULL"
> 
> # works fine
> tt[[1,1]]
 [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"
> 
> # the prototype allows subscripting and assigning to subscripted such objects 
> 
> # erroneously NULL in R
> tt[1,1]
[[1]]
NULL

> 
> # erroneously NULL in R
> tt[1,]
[[1]]
NULL

[[2]]
NULL

> 
> # erroneously NULL in R
> tt[, 1]
[[1]]
NULL

[[2]]
NULL

[[3]]
NULL

> 
> # erroneously NULL in R
> tt[,]
     [,1]   [,2]  
[1,] "NULL" "NULL"
[2,] "NULL" "NULL"
[3,] "NULL" "NULL"
> 
> # fine in R
> tt[]
     [,1]           [,2]  
[1,] "Character,26" "NULL"
[2,] "NULL"         "NULL"
[3,] "NULL"         "NULL"
> 
> # fine in R
> tt[cbind(1,1)]
[[1]]
 [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"

> 
> # of course the same problems in assignments 
> tt[1,1] <- tt[1,1]
Error: incompatible types in subset assignment
> tt[1,1] <- list(letters)
Error: incompatible types in subset assignment
> tt[1,] <- tt[1,]
Error: incompatible types in subset assignment
> tt[,1] <- tt[,1]
Error: incompatible types in subset assignment
> tt[,] <- tt[,]
Error: incompatible types in subset assignment
> 
> # and again fine
> tt[[1]] <- tt[[1]] 
> tt[] <- tt[]
> tt[cbind(1,1)] <- tt[cbind(1,1)] 
> 


# the prototype allows for the following, which fails in R
matrix(vector("list", 6), 3, 2)

# however the desired object seems to be legally in R as we get the same via
tt <- vector("list", 6)
dim(tt) <- c(3,2)
tt

# preparing to show further problems
tt[[1,1]] <- letters
tt

# works fine
tt[[1,1]]

# the prototype allows subscripting and assigning to subscripted such objects 

# erroneously NULL in R
tt[1,1]

# erroneously NULL in R
tt[1,]

# erroneously NULL in R
tt[, 1]

# erroneously NULL in R
tt[,]

# fine in R
tt[]

# fine in R
tt[cbind(1,1)]

# of course the same problems in assignments 
tt[1,1] <- tt[1,1]
tt[1,1] <- list(letters)
tt[1,] <- tt[1,]
tt[,1] <- tt[,1]
tt[,] <- tt[,]

# and again fine
tt[[1]] <- tt[[1]] 
tt[] <- tt[]
tt[cbind(1,1)] <- tt[cbind(1,1)] 



> version
         _              
platform i386-pc-mingw32
arch     x86            
os       Win32          
system   x86, Win32     
status                  
major    1              
minor    4.1            
year     2002           
month    01             
day      30             
language R 



Best regards

Jens Oehlschlaegel

________________________________________________________________
Keine verlorenen Lotto-Quittungen, keine vergessenen Gewinne mehr! 
Beim WEB.DE Lottoservice: http://tippen2.web.de/?x=13




-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._