Skip to content
Prev 55199 / 63424 Next

unlist errors on a nested list of empty lists

On 08/05/2018 1:48 PM, Steven Nydick wrote:
The error comes from the line

structure(res, levels = lv, names = nm, class = "factor")

which is called because unlist() thinks that some entry is a factor, 
with NULL levels and NULL names.  It's not legal for a factor to have 
NULL levels.  Probably it should never get here; the earlier test

if (.Internal(islistfactor(x, recursive))) {

should have been false, and then the result would have been

.Internal(unlist(x, recursive, use.names))

(with both recursive and use.names being TRUE), which returns NULL.

Duncan Murdoch