I am having problems using the testthat tolerance parameter when I check if two data_frames are equal. Here is a simple example with two data frames:
library(dplyr)
library(testthat)
d1 = data_frame(a = c(1, 1),
b = c(2, 2))
d2 = data_frame(a = c(1, 1.00001),
b = c(2, 2))
When I check for equality, testthat throws an error even with a sufficiently high tolerance value:
expect_equal(d1, d2,
tolerance = 0.01)
When comparing individual vectors, an error does not occur:
expect_equal(d1$a, d2$a,
tolerance = 0.01)
expect_equal(d1$b, d2$b,
tolerance = 0.01)
Any suggestions? I assume that I am using the expect_equal function incorrectly, but I donโt know how to solve it, other than running expect_equal on separate columns of the data frame.
Here are the versions of the package I'm using:
packageVersion("dplyr")
# [1] โ0.4.3โ
packageVersion("testthat")
# [1] โ0.11.0โ
source
share