Flatten recursive list

前端 未结 4 1180
无人共我
无人共我 2021-02-14 09:33

There are quite a few questions apparently on this topic, but I can\'t see any general solution proposed: I have a deeply recursive list and want to flatten it into a single lis

4条回答
  •  孤城傲影
    2021-02-14 09:57

    rrapply in the rrapply package is a generalization of rapply that can flatten the nested list into a list of leaves. dfaslist=FALSE will cause data frames to be regarded as leaves rather than being recursed into.

    library(rrapply)
    
    rrapply(d, f = identity, dfaslist = FALSE, how = "flatten")
    

提交回复
热议问题