-
Help
DescriptionI have a workflow where i fit 2 models for different customer types and then assess the models using Failed to evaluate glue component {customer_type}
Caused by error:
! object 'customer_type' not found below is a simplified example of my pipeline: list(
tar_target(
name = analysis_data,
make_analysis_data(data)
),
tar_target(
customer_type,
c("US", "Intl"),
),
tar_target(
name = UMAP,
train_umap(analysis_data, customer_type= customer_type),
pattern = map(customer_type),
deployment = "worker"
),
# Target to render the UMAP assessment report
tar_target(
name = assess_UMAP,
{
# Dynamically construct the output file name
output_file <- glue::glue("assess-UMAP-{customer_type}.html")
# Render the report with tar_render
tar_render(
path = "R/reports/assess-UMAP.qmd",
params = list(
analysis_data_param = analysis_data,
customer_type_param = customer_type,
model_path_param = UMAP
),
output_file = output_file,
output_dir = output_dir, # defined in _targets.R
)
},
pattern = map(customer_type, UMAP),
format = "file"
)
) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
library(targets)
list(
tar_target(
name = analysis_data,
make_analysis_data(data)
),
tar_target(
customer_type,
c("US", "Intl"),
),
tar_target(
name = UMAP,
train_umap(analysis_data, customer_type= customer_type),
pattern = map(customer_type),
deployment = "worker"
),
tar_target(
name = report_file,
command = "R/reports/assess-UMAP.qmd",
format = "file"
),
tar_target(
name = assess_UMAP,
command = {
rmarkdown::render(report_file, ...)
WRITE_OUTPUT_FILE_HERE
},
pattern = map(customer_type, UMAP),
format = "file"
)
) |
Beta Was this translation helpful? Give feedback.
tar_render()
is itself a target, so nesting it insidetar_target()
is probably not what you're going for. In your case, I would do something like: