tests/testthat/test-httr2.R

test_that("resp_body_csv keeps `NA` country codes", {
  resp <- httr2::response(
    status_code = 200L,
    headers = list("content-type" = "text/csv"),
    body = charToRaw("country,country_code,amount\nNamibia,NA,1.5\nBrazil,BR,\n")
  )
  res <- resp_body_csv(resp)
  expect_equal(res$country_code, c("NA", "BR"))
  expect_equal(res$amount, c(1.5, NA))
})

Try the worldbank package in your browser

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

worldbank documentation built on Aug. 21, 2026, 9:07 a.m.