Arithmetic operators for Polars objects
Description
Arithmetic operators for Polars objects
Usage
## S3 method for class 'polars_expr'
e1 + e2
# S3 method for class 'polars_expr'
e1 - e2
# S3 method for class 'polars_expr'
e1 * e2
# S3 method for class 'polars_expr'
e1 / e2
# S3 method for class 'polars_expr'
e1 %% e2
# S3 method for class 'polars_expr'
e1 %/% e2
# S3 method for class 'polars_expr'
e1 ^ e2
# S3 method for class 'polars_expr'
e1 < e2
Arguments
e1 , e2
|
Polars objects of numeric type or objects that can be coerced to a
polars object of numeric type. Only + can work with two
string inputs.
|
Value
A Polars object the same type as the input.
See Also
-
\
$add() -
\
$sub() -
\
$mul() -
\
$true_div() -
\
$pow() -
\
$mod() -
\
$floor_div()
Examples
#> [(5.0) + (10.0)]
#> [(5.0) + (10.0)]
#> [(5.0) + (10.0)]
#> 1.0
#> [(5.0) + ("10")]
#> <error/rlang_error>
#> Error:
#> ! Evaluation failed in `$select()`.
#> Caused by error:
#> ! Evaluation failed in `$collect()`.
#> Caused by error:
#> ! Invalid operation: arithmetic on string and numeric not allowed, try an explicit cast first
#>
#> Resolved plan until failure:
#>
#> ---> FAILED HERE RESOLVING 'sink' <---
#> SELECT [[(5.0) + ("10")]]
#> FROM
#> DF []; PROJECT */0 COLUMNS
#> ---
#> Backtrace:
#> ▆
#> 1. ├─base::tryCatch(pl$select(expr), error = function(e) e)
#> 2. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 3. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 4. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 5. └─pl$select(expr)
#> 6. └─pl$DataFrame()$select(...) at neo-r-polars/R/functions-lazy.R:12:3
#> 7. ├─polars:::wrap(self$lazy()$select(...)$collect(`_eager` = TRUE)) at neo-r-polars/R/dataframe-frame.R:367:3
#> 8. │ └─rlang::try_fetch(...) at neo-r-polars/R/utils-wrap.R:3:3
#> 9. │ ├─base::tryCatch(...)
#> 10. │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 11. │ │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 12. │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 13. │ └─base::withCallingHandlers(...)
#> 14. └─self$lazy()$select(...)$collect(`_eager` = TRUE) at neo-r-polars/R/utils-wrap.R:3:3
#> 15. ├─polars:::wrap(...) at neo-r-polars/R/lazyframe-frame.R:284:3
#> 16. │ └─rlang::try_fetch(...) at neo-r-polars/R/utils-wrap.R:3:3
#> 17. │ ├─base::tryCatch(...)
#> 18. │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 19. │ │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 20. │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 21. │ └─base::withCallingHandlers(...)
#> 22. └─ldf$collect(engine) at neo-r-polars/R/lazyframe-frame.R:331:5
#> 23. └─polars:::.savvy_wrap_PlRDataFrame(...) at neo-r-polars/R/000-wrappers.R:3579:5
#> shape: (1, 1)
#> ┌─────────┐
#> │ literal │
#> │ --- │
#> │ str │
#> ╞═════════╡
#> │ ab │
#> └─────────┘
#> shape: (1,)
#> Series: '' [f64]
#> [
#> 15.0
#> ]
#> shape: (1,)
#> Series: '' [f64]
#> [
#> 5.0
#> ]
#> shape: (1,)
#> Series: '' [f64]
#> [
#> -5.0
#> ]