tests/testthat/test-part_matrix_to_vec.R

context("partition matrix to vector")

test_that(
  "part_matrix_to_vector returns the index of the nonzero column for each row", {
    
    test_matrix <- matrix(
      c(
        1, 0, 0,
        1, 0, 0,
        0, 0, 1,
        0, 1, 0,
        0, 0, 1,
        0, 1, 0
      ),
      ncol = 3, byrow = TRUE
    )
    
    expect_equal(part_matrix_to_vector(test_matrix), c(1, 1, 3, 2, 3, 2))
    
  })

Try the biclustermd package in your browser

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

biclustermd documentation built on June 17, 2021, 5:11 p.m.