Skip to content

Commit

Permalink
error message if ggplot2 not installed, also return plot object
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennebacher committed Oct 20, 2023
1 parent aaf8809 commit 6085a84
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/lazyframe__lazy.R
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,10 @@ LazyFrame_profile = function(
.pr$LazyFrame$profile() |>
unwrap("in $profile()")

if (isTRUE(show_plot) && requireNamespace("ggplot2", quietly = TRUE)) {
if (isTRUE(show_plot)) {
if (!requireNamespace("ggplot2", quietly = TRUE)) {
stop('The package "ggplot2" is required.')
}
timings = out$profile$to_data_frame()
timings$node = factor(timings$node, levels = unique(timings$node))
total_timing = max(timings$end)
Expand Down Expand Up @@ -1498,6 +1501,7 @@ LazyFrame_profile = function(
}

print(plot)
out[["plot"]] = plot
}

out
Expand Down

0 comments on commit 6085a84

Please sign in to comment.