tests/testthat/test-wider_dt.R

test_that("convert data.frame from long to wide", {

  stocks = data.table(
    time = as.Date('2009-01-01') + 0:9,
    X = rnorm(10, 0, 1),
    Y = rnorm(10, 0, 2),
    Z = rnorm(10, 0, 4)
  )

  stocks %>%
    longer_dt(time) -> longer_stocks

  expect_equal(
    longer_stocks %>%
      wider_dt("time",
               name = "name",
               value = "value"),
    stocks,check.attributes = FALSE
  )
})

Try the tidyfst package in your browser

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

tidyfst documentation built on Sept. 16, 2024, 9:06 a.m.