Bug 15854 - problem to relist list containing NULL elements
Summary: problem to relist list containing NULL elements
Status: NEW
Alias: None
Product: R
Classification: Unclassified
Component: Analyses (show other bugs)
Version: R 3.1.0
Hardware: All All
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2014-07-06 13:31 UTC by Erik Wright
Modified: 2014-07-06 13:31 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Wright 2014-07-06 13:31:27 UTC
This is related to bug 15499 but different.  This previous bug fixed the problem for the case where there were zero-length elements in the list, but not NULL elements.  So R-devel still errors for this example:

x <- list(NULL, a=1:3, b=5:7)
y <- unlist(as.relistable(x))
utils::relist(y)

One potential fix is to replace this code on Line 124:
seq_along(skeleton)

in relist.R to this:
which(unlist(lapply(skeleton, length)) > 0)

Then it does not error:
x <- list(NULL, a=1:3, b=5:7)
y <- unlist(as.relistable(x))
relist(y)

Thanks,
Erik