Skip to content

Commit

Permalink
feat: #9 #10 add function recursive_check to check for presence of de…
Browse files Browse the repository at this point in the history
…eply nested elements (perhaps there's a better way to do this?) so that get_multiplevel_elements() can get elements that are not direct children of entities or attributes
  • Loading branch information
atn38 committed Apr 11, 2022
1 parent 1736a66 commit 60c4d16
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,29 @@ parse_packageId <- function(full_id) {
return(x)
}

#' Title
#'
#' @param x (list) node to check
#' @param element_names (character) Name or vector of descending names to check
#'
#' @return
#'
#' @examples
recursive_check <- function(x, element_names) {
check <- TRUE
for (i in seq_along(element_names)) {
if (i == 1) {
if (!element_names[[1]] %in% names(x))
check <- FALSE
}
else {
if (!element_names[[i]] %in% names(x[[element_names[1:(i - 1)]]]))
check <- FALSE
}
}
return(check)
}


#' Remove context
#'
Expand Down

0 comments on commit 60c4d16

Please sign in to comment.