Skip to content

Are two Series equal?

Source code

Description

This checks whether two Series are equal in values and in their name.

Usage

<Series>$equals(other, null_equal = FALSE, strict = FALSE)

Arguments

other Series to compare with.
null_equal If TRUE, consider that null values are equal. Overridden by strict.
strict If TRUE, do not allow similar DataType comparison. Overrides null_equal.

Value

A logical value

Examples

library(polars)

as_polars_series(1:4)$equals(as_polars_series(1:4))
#> [1] TRUE
# names are different
as_polars_series(1:4, "bob")$equals(as_polars_series(1:4))
#> [1] TRUE
# nulls are different by default
as_polars_series(c(1:4, NA))$equals(as_polars_series(c(1:4, NA)))
#> [1] FALSE
as_polars_series(c(1:4, NA))$equals(as_polars_series(c(1:4, NA)), null_equal = TRUE)
#> [1] TRUE
# datatypes are ignored by default
as_polars_series(1:4)$cast(pl$Int16)$equals(as_polars_series(1:4))
#> [1] TRUE
as_polars_series(1:4)$cast(pl$Int16)$equals(as_polars_series(1:4), strict = TRUE)
#> [1] FALSE