tests/testthat/test-apply_row.R

test_that("apply_col and apply_row works", {
    mat <- matrix(rnorm(4*6), 4, 6)
    
    mat_bycol <- apply_col(mat, c(1, 1, 2, 2), colMeans)
    mat_byrow <- apply_row(mat, c(1, 1, 2, 2, 3, 3), rowMeans)
    
    expect_equal(dim(mat_bycol), c(2, 6))
    expect_equal(dim(mat_byrow), c(4, 3))
})

Try the rtrend package in your browser

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

rtrend documentation built on June 22, 2024, 11:39 a.m.