tests/testthat/test-indexing.R

test_that("Get the Last Elements of a Vector or List", {
    expect_equal(getlast(1:5), 5)
    expect_equal(getlast(list(a = 1, b = 2, c = 3), 2), 2)
})

test_that("Get the First Elements of a Vector or List", {
    expect_equal(getfirst(1:5), 1)
    expect_equal(getfirst(list(a = 1, b = 2, c = 3), 2), 2)
})

Try the FastUtils package in your browser

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

FastUtils documentation built on Sept. 11, 2024, 5:13 p.m.