Skip to content

Commit

Permalink
feat: new function get_dataset_level_element #2 #9
Browse files Browse the repository at this point in the history
  • Loading branch information
atn38 committed Apr 26, 2022
1 parent 5b5c7d9 commit 18b5c35
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions R/get_datasetlevel_element.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#' Title
#'
#' @param corpus
#'
#' @return
#' @export
#'
#' @examples
get_datasetlevel_element <-
function(corpus, element_names, parse_function) {
vw <- list()
for (i in seq_along(corpus)) {
pk <- parse_packageId(names(corpus)[[i]])
scope <- pk[["scope"]]
id <- pk[["id"]]
rev <- pk[["rev"]]

ddf <- data.frame()
if (recursive_check(corpus[[i]][["dataset"]], element_names = element_names)) {
d <- handle_one(corpus[[i]][["dataset"]][[element_names]])
ddf <-
data.table::rbindlist(lapply(seq_along(d), function(x)
parse_function(d[[x]])), fill = TRUE)
n <- ncol(ddf)
cols <- c((n+1):(n+3), 1:n)
ddf$scope <- scope
ddf$id <- id
ddf$rev <- rev
ddf <- subset(ddf, select = cols)
}
vw[[i]] <- ddf
}
return(data.table::rbindlist(vw))
}

0 comments on commit 18b5c35

Please sign in to comment.