Bug 15499 - problem to relist list containing zero-length elements
problem to relist list containing zero-length elements
Status: CLOSED FIXED
Product: R
Classification: Unclassified
Component: Analyses
R 3.0.1
Other Mac OS X v10.8
: P1 major
Assigned To: R-core
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-22 07:19 UTC by Julien Prados
Modified: 2013-10-22 11:41 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.