We at STATWORX work a lot with R and we often use the same little helper function within our projects. These functions ease our daily work life by reducing repetitive code parts or by creating overviews of our projects. At first, there was no plan to make a package, but soon I realised, that it will be much easier to share and improve those functions, if they are within a package. Up till the 24th December I will present one function each day from
helfRlein. So, on the 2nd day of Christmas my true love gave to me…
What can it do?
This little helper removes missing values from a list.
y <- list(NA, c(1, NA), list(c(5:6, NA), NA, "A"))
There are two ways to remove the missing values, either only on the first level of the list or wihtin each sub level.
na_omitlist(y, recursive = FALSE)
[]  1 NA [] [][]  5 6 NA [][]  NA [][]  "A"
na_omitlist(y, recursive = TRUE)
[]  1 [] [][]  5 6 [][]  "A"
Have a merry advent season!