Skip to content
Prev 171585 / 398502 Next

how to NULL multiple variables of a df efficiently?

Stavros Macrakis wrote:
actually, you need one NULL per variable, but it suffices to provide a
list of *one* NULL, and it will be recycled:
   
    df[,c("var.a","var.b")] <- list(NULL)
as above, this works as well:

    df[, vars] = list(NULL)

and this, simplest of them all, works too:

    df[vars] = list(NULL)

vQ