Is there an easy way (i.e. a function) to determine the level of nesting in list?
I know there is str
which can be used to get this information. But is there something that simply gives back the result? And can I use such a function to get the names of all levels of alist (recursively) ?
相关问题
- R - Quantstart: Testing Strategy on Multiple Equit
- how to split a list into a given number of sub-lis
- Using predict with svyglm
- Reshape matrix by rows
- Extract P-Values from Dunnett Test into a Table by
相关文章
- List可以存储接口类型的数据吗?
-
C# List
.FindAll 时 空指针异常 - How to convert summary output to a data frame?
- What is the complexity of bisect algorithm?
- How to plot smoother curves in R
- Paste all possible diagonals of an n*n matrix or d
- ess-rdired: I get this error “no ESS process is as
- How to use doMC under Windows or alternative paral
A little recursive function can do this for you:
If you've got
package:testthat
, here's a test set:Apologies for using lower-case L in variable names. Readability fail.
You can now use
depth()
from thepurrr
package!Note: currently the function is part of the development version of
purrr
but will become part of the official CRAN version once the package gets a version bumpIf all elements are named, you could use this (from the code of
unlist
):