tests/testthat/test_rsquared.R

context("get R2 from linear regression")

test_that("rsquared() works", {
  
  x <- c(
    0.47757278, 0.783686054, 0.67713684,
    0.18449017, 0.525312408, 0.00814505,
    0.41764717, 0.211036512, 0.31190996, 
    0.14312053
    )
  
  y <- c(
    0.643053783, 0.7953037, 0.334161496, 
    0.529722084, 0.2850723, 0.796445325,
    0.169789078, 0.49695294, 0.17196189,
    0.871107961
    )
  
  expect_equal(rsquared(x, y), 0.0575, tolerance=1e-4)
  
})
  
  
ktbaek/krisr documentation built on Feb. 21, 2022, 12:07 a.m.