Skip to contents

A drop-in replacement for the targets targets::tar_target() pattern helper sample(), for use unquoted in the pattern argument of a tarpolyglot constructor. Like tarpolyglot_map(), on tar_target_rs() it compiles the extendr crate once in a companion <name>_rust_lib target and reuses it across the sampled branches; on tar_target_py() / tar_target_jl() it is exactly sample(). See tarpolyglot_map() for the full explanation and the compile-once mechanics.

Usage

tarpolyglot_sample(..., n)

Arguments

...

Upstream target(s) to branch over, with the same meaning as in the targets sample() pattern.

n

Number of branches to sample at random, as in the targets sample() pattern.

Value

This function is a marker consumed by the tarpolyglot constructors and is not meant to be evaluated on its own; calling it directly raises an error.

Examples

if (FALSE) { # \dontrun{
tarpolyglot::tar_target_rs(
  name = rs_rand, script = "square.rs", inputs = c(x = "vals"),
  post_script = "post.R", pattern = tarpolyglot_sample(vals, n = 2)
)
} # }