Revisión | 174946cb309a680d774faf60790a7c026391b902 (tree) |
---|---|
Tiempo | 2025-01-14 20:08:11 |
Autor | Lorenzo Isella <lorenzo.isella@gmai...> |
Commiter | Lorenzo Isella |
I fixed the equal_within function.
@@ -7290,10 +7290,13 @@ | ||
7290 | 7290 | stop("x and y must have the same length.") |
7291 | 7291 | } |
7292 | 7292 | |
7293 | - # Check for division by zero | |
7293 | + # Check for equality and division by zero | |
7294 | 7294 | res <- if_else( |
7295 | - (x == 0 | y == 0), FALSE, | |
7296 | - (abs(x - y) / abs(pmin(x, y))) <= percent / 100 | |
7295 | + x == y, TRUE, # Identical numbers always return TRUE | |
7296 | + if_else( | |
7297 | + (x == 0 | y == 0), FALSE, # If one is zero but not both, return FALSE | |
7298 | + (abs(x - y) / abs(pmin(x, y))) <= percent / 100 # Otherwise, check the percentage condition | |
7299 | + ) | |
7297 | 7300 | ) |
7298 | 7301 | |
7299 | 7302 | return(res) |
@@ -7301,7 +7304,6 @@ | ||
7301 | 7304 | |
7302 | 7305 | |
7303 | 7306 | |
7304 | - | |
7305 | 7307 | ## calculate_return <- function(x) { |
7306 | 7308 | |
7307 | 7309 |