From eea997786ce15f93cacb257afa93e8e22cdb4f3d Mon Sep 17 00:00:00 2001 From: Felipe Carlos Date: Fri, 12 Apr 2024 16:07:21 -0300 Subject: [PATCH] fix unavailable items properties handling --- R/items-funs.R | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/R/items-funs.R b/R/items-funs.R index 399392a9..65e3c527 100644 --- a/R/items-funs.R +++ b/R/items-funs.R @@ -695,9 +695,16 @@ items_as_tibble.doc_item <- function(items) { items_as_tibble.doc_items <- function(items) { check_items(items) non_atomic <- non_atomic_properties(items) + properties <- items_fields(items, "properties") data <- lapply(items$features, function(item) { + # fill unavailable properties + unavailable_properties <- setdiff(properties, names(item$properties)) + item$properties[unavailable_properties] <- NA + # update non-atomic properties item$properties[non_atomic] <- lapply(item$properties[non_atomic], list) - item$properties + # return properties from items in the same order + # to avoid errors in the `mapply` + item$properties[properties] }) data <- do.call(mapply, args = c(list(FUN = c, SIMPLIFY = FALSE), data)) structure(