tests/testthat/test-rownames.R

test_that("trun rownames to column or column to rownames", {

  expect_equal(
    mtcars %>% rn_col(),
    as.data.table(mtcars)[,rowname := rownames(mtcars)] %>%
      relocate_dt(rowname)
  )

  expect_equal(
    mtcars %>% rn_col("rn"),
    as.data.table(mtcars)[,rn := rownames(mtcars)] %>%
      relocate_dt(rn)
  )

  expect_equal(
    mtcars %>% rn_col() %>% col_rn(),
    mtcars
  )
})
hope-data-science/tidyfst documentation built on Sept. 23, 2024, 8:05 p.m.