Skip to content

Commit

Permalink
sort out utils
Browse files Browse the repository at this point in the history
  • Loading branch information
emitanaka committed Nov 10, 2023
1 parent 85df087 commit 8314d1d
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ print.edbl_fct <- function(x, ...) {

#' @export
`+.edbl` <- function(e1, e2) {

if(missing(e2)) {
cli::cli_abort(c("Cannot use {.code +} with a single argument",
i = "Did you accidentally put {.code +} on a new line?"))
Expand All @@ -373,11 +372,22 @@ print.edbl_fct <- function(x, ...) {
if(nrow(fedges2)) {
from1 <- prov1$fct_id(name = prov2$fct_names(id = fedges2$from))
to1 <- prov1$fct_id(name = prov2$fct_names(id = fedges2$to))
prov1$append_fct_edges(from = from1,
to = to1,
type = fedges2$type,
group = ifelse(is.na(fedges2$group), FALSE, fedges2$group),
attrs = fedges2$attrs)
needs_group_id <- !is.na(fedges2$group)
if(sum(needs_group_id)) {
prov1$append_fct_edges(from = from1[needs_group_id],
to = to1[needs_group_id],
type = fedges2$type[needs_group_id],
group = TRUE,
# FIXME: this needs to be modified if attrs is data.frame!
attrs = fedges2$attrs[needs_group_id])
} else if(sum(!needs_group_id)) {
prov1$append_fct_edges(from = from1[!needs_group_id],
to = to1[!needs_group_id],
type = fedges2$type[!needs_group_id],
group = FALSE,
# FIXME: this needs to be modified if attrs is data.frame!
attrs = fedges2$attrs[!needs_group_id])
}
}
# add level nodes and edges from e2
missing_cols <- function(col, df) {
Expand Down

0 comments on commit 8314d1d

Please sign in to comment.