Create a literal value
Description
Create a literal value
Usage
pl$lit(x)
Arguments
x
|
A vector of any length |
Details
pl$lit(NULL)
translates into a polars null
.
Value
Expr
Examples
library("polars")
# values to literal, explicit `pl$lit(42)` implicit `+ 2`
pl$col("some_column") / pl$lit(42) + 2
#> polars Expr: [([(col("some_column")) // (dyn float: 42.0)]) + (dyn float: 2.0)]
# vector to literal explicitly via Series and back again
# R vector to expression and back again
pl$select(pl$lit(as_polars_series(1:4)))$to_list()[[1L]]
#> [1] 1 2 3 4
#> [1] 1 2 3 4
#> shape: (4, 1)
#> ┌─────┐
#> │ │
#> │ --- │
#> │ i32 │
#> ╞═════╡
#> │ 1 │
#> │ 2 │
#> │ 3 │
#> │ 4 │
#> └─────┘
#> polars Series: shape: (4,)
#> Series: '' [i32]
#> [
#> 1
#> 2
#> 3
#> 4
#> ]
#> polars Expr: [([(dyn float: 2.0) + (Series)]) // (Series)]