Skip to content

Creating a target for a plot and a file #135

Closed Answered by wlandau
Shians asked this question in Help
Discussion options

You must be logged in to vote

I will have to think about officially supporting this in tarchetypes. But for now, you can use your own target factory.

# _targets.R file
library(targets)
library(tarchetypes)

tar_plot <- function(name, fun_plot, fun_save, path) {
  name <- substitute(name)
  prefix <- as.character(name)
  name_plot <- paste0(name, "_plot")
  name_file <- paste0(name, "_file")
  list(
    targets::tar_target_raw(
      name = name_plot,
      command = substitute(
        fun(),
        env = list(fun = substitute(fun_plot))
      )
    ),
    targets::tar_target_raw(
      name = name_file,
      command = substitute(
        fun(plot, path),
        env = list(
          fun = substitute(fun_save),
   …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Shians
Comment options

@wlandau
Comment options

Answer selected by Shians
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants