Remove NULL values variables from a list
removeNULL.RdUnlike vectors, lists can hold objects with value NULL. This gets rid of them.
Details
This version is NOT recursive
plyr::rbind.fill uses an experimental function that I choose to avoid. This is the "safe" version.
Examples
## Note it is non-recursive, NULL remains in e
x <- list(a = rnorm(5), b = NULL, c = rnorm(5), d = NULL,
e = list(f = rnorm(2), g = NULL))
x
#> $a
#> [1] -0.3877984 0.7586402 -1.2093726 -0.9351637 0.7008320
#>
#> $b
#> NULL
#>
#> $c
#> [1] 1.3981987 -2.2991663 1.3683319 -0.5132260 -0.3815087
#>
#> $d
#> NULL
#>
#> $e
#> $e$f
#> [1] -0.03261461 -0.54644296
#>
#> $e$g
#> NULL
#>
#>
removeNULL(x)
#> $a
#> [1] -0.3877984 0.7586402 -1.2093726 -0.9351637 0.7008320
#>
#> $c
#> [1] 1.3981987 -2.2991663 1.3683319 -0.5132260 -0.3815087
#>
#> $e
#> $e$f
#> [1] -0.03261461 -0.54644296
#>
#> $e$g
#> NULL
#>
#>