Skip to content

Commit

Permalink
Use lapply()
Browse files Browse the repository at this point in the history
Signed-off-by: Liang Zhang <[email protected]>
  • Loading branch information
psychelzh committed Apr 4, 2024
1 parent da1de1e commit 510f4b9
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions R/targets.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,21 @@ tar_prep_iquizoo <- function(params, ...,
#' @return A list of target objects.
#' @export
tar_prep_hash <- function(contents, templates = setup_templates()) {
tarchetypes::tar_map(
data.frame(project_id = as.character(unique(contents$project_id))),
targets::tar_target_raw(
"progress_hash",
bquote(
fetch_iquizoo(
.(read_file(templates[["progress_hash"]])),
params = list(project_id)
)
),
packages = "tarflow.iquizoo",
cue = targets::tar_cue("always")
)
lapply(
as.character(unique(contents$project_id)),
\(project_id) {
targets::tar_target_raw(
paste0("progress_hash_", project_id),
bquote(
fetch_iquizoo(
.(read_file(templates[["progress_hash"]])),
params = list(.(project_id))
)
),
packages = "tarflow.iquizoo",
cue = targets::tar_cue("always")
)
}
)
}

Expand Down

0 comments on commit 510f4b9

Please sign in to comment.