[Rd] Odd behaviour in within.list() when deleting 2+ variables

Hong Ooi hongooi at microsoft.com
Mon Jun 26 04:40:09 CEST 2017


The behaviour of within() with list input changes if you delete 2 or more variables, compared to deleting one:

l <- list(x=1, y=2, z=3)

within(l,
{
    rm(z)
})
#$x
#[1] 1
#
#$y
#[1] 2


within(l, {
    rm(y)
    rm(z)
})
#$x
#[1] 1
#
#$y
#NULL
#
#$z
#NULL


When 2 or more variables are deleted, the list entries are instead set to NULL. Is this intended?



More information about the R-devel mailing list