packrat/lib/x86_64-w64-mingw32/3.6.1/jsonlite/tests/testthat/test-toJSON-factor.R

context("toJSON Factor")

test_that("Encoding Factor Objects", {
  expect_that(fromJSON(toJSON(iris$Species)), is_identical_to(as.character(iris$Species)));
  expect_that(fromJSON(toJSON(iris$Species[1])), is_identical_to(as.character(iris$Species[1])));
  expect_that(fromJSON(toJSON(iris$Species, factor="integer")), equals(structure(unclass(iris$Species), levels=NULL)));
});
jmcascalheira/LGMIberiaCluster documentation built on June 8, 2021, 10 a.m.