R/neptune_file_as_image.R

Defines functions neptune_file_as_image

Documented in neptune_file_as_image

neptune_file_as_image <-
  function(x, ...) {
    if ("ggplot" %in% class(x)) {
      pth <- paste0(tempfile(), ".png")
      ggplot2::ggsave(
        x,
        filename = pth,
        ...
      )
      file_ <-
        reticulate::import("neptune.new.types")$File(path = pth)
      return(file_)
    }
    reticulate::import("neptune.new.types")$File$as_image(x)
  }
neptune-ai/neptune-r documentation built on Aug. 21, 2023, 6:51 p.m.