Skip to content

Map alias of expression with an R function

Source code

Description

Rename the output of an expression by mapping a function over the root name.

Usage

<Expr>$name$map(fun)

Arguments

fun an R function which takes a string as input and return a string

Value

Expr

Examples

library(polars)

pl$DataFrame(list(alice = 1:3))$select(
  pl$col("alice")$alias("joe_is_not_root")$name$map(\(x) paste0(x, "_and_bob"))
)
#> shape: (3, 1)
#> ┌───────────────┐
#> │ alice_and_bob │
#> │ ---           │
#> │ i32           │
#> ╞═══════════════╡
#> │ 1             │
#> │ 2             │
#> │ 3             │
#> └───────────────┘