tests/testthat/test-fscale.R

context("Standardize a vector")

test_that("fscale (in c++) works", {

    set.seed(20171201)

    x <- rnorm(24, 20, 5)
    y <- rnorm(24, 20, 5)
    expect_equivalent(fscale(x, y), as.numeric(scale(x)))

    # a couple of NAs in x
    x[2] <- x[24] <- NA
    expect_equivalent(fscale(x, y), as.numeric(scale(x)))

    # a couple of NAs in y as well
    y[3] <- y[12] <- NA
    z <- x
    z[3] <- z[12] <- NA
    expect_equivalent(fscale(x, y), as.numeric(scale(z)))

})

Try the lineup2 package in your browser

Any scripts or data that you put into this service are public.

lineup2 documentation built on June 15, 2021, 9:07 a.m.