# http://stackoverflow.com/questions/30487010/recursively-apply-function-to-list-elements
recursive_browse_list <- function(x) {
if(is.list(x)) {
# (OPTIONAL) DO HERE SOME OPERATION ON LIST
# example here : add names to list which do not have name
if(is.null(names(x))) {
if(length(x)>0) names(x) <- as.list(1:length(x))
}
lapply(x, recursive_browse_list)
} else {
# DO HERE SOME OPERATION ON x
}
}
Last active
January 31, 2018 14:40
-
-
Save StudioEtrange/572b786e28e897c6b563 to your computer and use it in GitHub Desktop.
R : browse recursivly each item of a complex list (which include list) and apply operation to each leave
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment