@@ -201,7 +201,8 @@ test_that("simple corTestDS, some, with na, pearson", {
201201
202202 # extract information from the results
203203 t_stat <- res $ `Correlation test` $ statistic [[1 ]]
204- df <- res $ `Number of pairwise complete cases`
204+ # degrees of freedom
205+ df <- res $ `Number of pairwise complete cases` - 2
205206 # re-calculate the value for r (correlation)
206207 # # t_stat <- sqrt(df) * r / sqrt(1 - r^2) # Equation 1
207208 # # calculate intermediate coefficient, derived from Equation 1
@@ -212,10 +213,10 @@ test_that("simple corTestDS, some, with na, pearson", {
212213 # if testing on Apple M1: due to numeric precision
213214 if (getElement(Sys.info(), " sysname" ) == " Darwin" &&
214215 getElement(R.version , " arch" ) == " aarch64" ) {
215- # lower tolerance, expect failure, due to numeric precision
216- expect_error(expect_equal( r , 1L , tolerance = 1E-16 ))
217- # higher tolerance, expect success
218- expect_equal( r , 1L , tolerance = 1E-8 )
216+ # t-stat should be a very large value, because r ~ 1, but not exactly 1
217+ expect_false(is.infinite( t_stat ))
218+ # r ~ 1
219+ expect_false(is.nan( r ) )
219220 }
220221 else { # other architectures
221222 expect_true(is.infinite(t_stat ))
0 commit comments