Skip to content

Commit

Permalink
simplify?
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Oct 1, 2024
1 parent 0dbc060 commit ce09540
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions R/check_dag.R
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,13 @@ check_dag <- function(...,
# y = c(score = 3, exp = 3, b = 2, c = 4)
# )
if (!is.null(coords) && (length(coords) != 2 || !identical(names(coords), c("x", "y")))) {
# transform list, so we split x and y coordinates. we now have all
# x- and y- coordinates in a separate row
out <- t(do.call(rbind, coords))
# add back to list and name elements
coords <- list(out[1, ], out[2, ])
names(coords) <- c("x", "y")
# transform list into data frame, split x and y coordinates into columns
coords <- datawizard::rownames_as_column(
stats::setNames(as.data.frame(do.call(rbind, coords)), c("x", "y")),
"name"
)
# reorder
coords <- coords[c("x", "y", "name")]
}
coords
}
Expand Down

0 comments on commit ce09540

Please sign in to comment.