Jam-specific recursive apply
Usage
jam_rapply(x, FUN, how = c("unlist", "list"), ...)
Arguments
- x
list
- FUN
function
to be called on non-list elements inx
.- how
character
string indicating whether to return thelist
or whether to callunlist()
on the result.- ...
additional arguments are passed to
FUN
.
Details
This function is a very lightweight customization to base::rapply()
,
specifically that it does not remove NULL
entries.
See also
Other jam list functions:
cPaste()
,
heads()
,
list2df()
,
mergeAllXY()
,
mixedSorts()
,
rbindList()
,
relist_named()
,
rlengths()
,
sclass()
,
sdim()
,
uniques()
,
unnestList()
Examples
L <- list(entryA=c("miR-112", "miR-12", "miR-112"),
entryB=factor(c("A","B","A","B"),
levels=c("B","A")),
entryC=factor(c("C","A","B","B","C"),
levels=c("A","B","C")),
entryNULL=NULL)
rapply(L, length)
#> entryA entryB entryC
#> 3 4 5
jam_rapply(L, length)
#> entryA entryB entryC entryNULL
#> 3 4 5 0
L0 <- list(A=1:3, B=list(C=1:3, D=4:5, E=NULL));
rapply(L0, length)
#> A B.C B.D
#> 3 3 2
jam_rapply(L0, length)
#> A B.C B.D B.E
#> 3 3 2 0