Michael Lawrence
2011-Aug-11 11:07 UTC
[Rd] relist.list broken for skeletons with empty elements
Hi guys, This seems wrong:> x <- list(2, numeric()) > relist(unlist(x), x)[[1]] [1] 2 [[2]] [1] NA 2 Here is the definition: function (flesh, skeleton = attr(flesh, "skeleton")) { ind <- 1L result <- skeleton for (i in seq_along(skeleton)) { size <- length(unlist(result[[i]])) result[[i]] <- relist(flesh[ind:(ind + size - 1L)], result[[i]]) ind <- ind + size } result } That should probably use seq(..., length=size) or something instead of the ":" function. Thanks, Michael [[alternative HTML version deleted]]