Identify similarities and differences between two R vectors (for the numbers the comparison is not exact, an epsilon is used).

vector_comparison(
  first_vector,
  second_vector,
  comparison_type,
  output,
  epsilon = 1.5e-08
)

Arguments

first_vector

vector expected.

second_vector

vector expected.

comparison_type

character expected. Type of comparison expected, you can choose between "difference", "equal", "less", "greater", "less_equal" or "greater_equal". "Difference" highlight element(s) of the first vector not present in the second, "equal" check if two vectors are exactly the same, "less" check if the elements of the first vector are strictly less than their pair in the second vector , "greater" check if the elements of the first vector are strictly greater than their pair in the second vector, "less_equal" check if the elements of the first vector are less than or equal to their pair in the second vector or "greater_equal" check if the elements of the first vector are greater than or equal to their pair in the second vector.

output

character expected. Kind of expected output. You can choose between "message", "report" or "logical".

epsilon

numeric expected. Default values: 1.5e-8. Tolerance of comparison for numeric value, following the problem caused by IEEE Standard 754.

Examples

vector_comparison(
  first_vector = c(1, 2, 3, 5),
  second_vector = c(1, 2, 4, 3),
  comparison_type = "difference",
  output = "report"
)
#> # A tibble: 4 × 2
#>   first_vector logical
#>          <dbl> <lgl>  
#> 1            1 TRUE   
#> 2            2 TRUE   
#> 3            3 TRUE   
#> 4            5 FALSE