Bug 15499

Summary: problem to relist list containing zero-length elements
Product: R Reporter: Julien Prados <julien.prados>
Component: AnalysesAssignee: R-core <R-core>
Status: CLOSED FIXED    
Severity: major CC: julien.prados, murdoch
Priority: P1    
Version: R 3.0.1   
Hardware: Other   
OS: Mac OS X v10.8   

Description Julien Prados 2013-10-22 07:19:13 UTC
NOTE: 
I use R 3.0.2 (not available in the selection box)

BUG DESCRIPTION:
It seems the relist() function is not working properly when the skeleton list contains zero-length elements.

EXAMPLE:
For example, the following code doesn't return the expected result. We would expect K and L to be identical but it is not the case:

> L <- list(integer(0),1:3)
> K <- relist(unlist(L),L)
> L
[[1]]
integer(0)

[[2]]
[1] 1 2 3

> K
[[1]]
[1] 1

[[2]]
[1] 1 2 3

Furthermore, it seems the behavior is slightly different when the zero length vector is at the end of the list:

> L <- list(1:3,integer(0))
> K <- relist(unlist(L),L)
> L
[[1]]
[1] 1 2 3

[[2]]
integer(0)

> K
[[1]]
[1] 1 2 3

[[2]]
[1] NA  3



CONFIGURATION DETAILS:
> version
               _                           
platform       x86_64-apple-darwin10.8.0   
arch           x86_64                      
os             darwin10.8.0                
system         x86_64, darwin10.8.0        
status                                     
major          3                           
minor          0.2                         
year           2013                        
month          09                          
day            25                          
svn rev        63987                       
language       R                           
version.string R version 3.0.2 (2013-09-25)
nickname       Frisbee Sailing
Comment 1 Duncan Murdoch 2013-10-22 11:41:08 UTC
This is a simple programming error, using : to try to generate a length zero list.  I will fix in R-devel and R-patched.