inst/tinytest/import/test-import_data.R

d <- get(
  utils::data(list="cars", package = "datasets", envir = environment())
)
expect_equal(
  import_data("datasets", "cars") |> head(),
  head(d)
)

expect_error(
  import_data("datasets", c("cars", "cairo")),
  pattern = "only a single dataset and a single package can be given"
)

expect_error(
  import_data(c("datasets", "datasets"), "airmiles"),
  pattern = "only a single dataset and a single package can be given"
)

expect_error(
  import_data("datasets", "airmiles", lib.loc = mean),
  pattern = "`lib.loc` must be a character vector with at least one library path"
)

Try the tinycodet package in your browser

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

tinycodet documentation built on Sept. 12, 2024, 7:03 a.m.