Return an expression representing a literal value
Description
This function is a shorthand for as_polars_expr(x, as_lit =
TRUE)
and in most cases, the actual conversion is done by
as_polars_series()
.
Usage
pl$lit(value, dtype = NULL)
Arguments
value
|
An R object. Passed as the x param of
as_polars_expr() .
|
dtype
|
A polars data type or NULL (default). If not
NULL , casted to the specified data type.
|
Value
A polars expression
See Also
-
as_polars_series()
: R -\> Polars type mapping is mostly defined by this function. -
as_polars_expr()
: Internal implementation ofpl$lit()
.
Examples
#> 1
#> 5.5
#> null
#> "foo_bar"
# Generally, for a vector (an R object) becomes a Series with length 1,
# it is converted to a Series and then get the first value to become a scalar literal.
pl$lit(as.Date("2021-01-20"))
#> 2021-01-20
#> 2023-03-31 10:30:45
#> {1.0,"foo"}
#> Series[literal]
#> Series[x]