Skip to content

Get the last value.

Source code

Description

This function has different behavior depending on the input type:

  • Missing -\> Takes last column of a context.
  • Character vectors -\> Syntactic sugar for pl$col(…)$last().

Usage

pl$last(...)

Arguments

Characters indicating the column names (passed to pl$col(), see ?pl_col for details), or empty. If empty (default), returns an expression to take the last column of the context instead.

Value

Expr

See Also

  • \$last()

Examples

library(polars)

df = pl$DataFrame(
  a = c(1, 8, 3),
  b = c(4, 5, 2),
  c = c("foo", "bar", "baz")
)

df$select(pl$last())
#> shape: (3, 1)
#> ┌─────┐
#> │ c   │
#> │ --- │
#> │ str │
#> ╞═════╡
#> │ foo │
#> │ bar │
#> │ baz │
#> └─────┘
df$select(pl$last("a"))
#> shape: (1, 1)
#> ┌─────┐
#> │ a   │
#> │ --- │
#> │ f64 │
#> ╞═════╡
#> │ 3.0 │
#> └─────┘
df$select(pl$last(c("b", "c")))
#> shape: (1, 2)
#> ┌─────┬─────┐
#> │ b   ┆ c   │
#> │ --- ┆ --- │
#> │ f64 ┆ str │
#> ╞═════╪═════╡
#> │ 2.0 ┆ baz │
#> └─────┴─────┘