Skip to content
Prev 52517 / 63424 Next

How to assign NULL value to pairlist element while keeping it a pairlist?

Thanks Luke.  Yes, this is what I wrote as a workaround in my original
post (and my first follow up):

expr[[2]][1] <- list(x = NULL)
expr[[2]] <- as.pairlist(expr[[2]])

but your

alist <- expr[[2]]
alist[1] <- list(NULL)
expr[[2]] <- as.pairlist(alist)

makes it a bit more clear what the issue is; a pairlist 'x' (here
expr[[2]] and expr) gets coerced to a plain list if one try to do a
`[<-()` assignment.  It would be nice / useful / less surprising /
more consistent(?) if it would remain a pairlist also in those cases.

/Henrik
On Wed, Oct 19, 2016 at 11:47 AM, <luke-tierney at uiowa.edu> wrote: