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.21951028 0.07162039 -0.38779843 0.75864023 -1.20937260
#>
#> $b
#> NULL
#>
#> $c
#> [1] -0.9351637 0.7008320 1.3981987 -2.2991663 1.3683319
#>
#> $d
#> NULL
#>
#> $e
#> $e$f
#> [1] -0.5132260 -0.3815087
#>
#> $e$g
#> NULL
#>
#>
removeNULL(x)
#> $a
#> [1] -0.21951028 0.07162039 -0.38779843 0.75864023 -1.20937260
#>
#> $c
#> [1] -0.9351637 0.7008320 1.3981987 -2.2991663 1.3683319
#>
#> $e
#> $e$f
#> [1] -0.5132260 -0.3815087
#>
#> $e$g
#> NULL
#>
#>