remove null element from list r
require(tidyverse)
# this works
compact(mylist)
# or this
mylist %>% discard(is.null)
# or this
# pipe "my_list" data object into function "keep()", make lambda function inside "keep()" to return TRUE FALSE.
mylist %>% keep( ~ !is.null(.) )