Skip to content

use_data: Provide ability to pass ascii to save() Β #1625

@JosiahParry

Description

@JosiahParry

CRAN checks require that all exported objects contain only ASCII letters. The base save() function provides the argument ascii to save an rda file as ASCII compliant. This argument is not made available by usethis.

Spatial CRS will often (and frustratingly) contain non-ASCII letters. When these objects are exported they do not pass CRAN checks when saved with usethis.

An example is below

guerry <- sf::st_as_sf(Guerry::gfrance85) |>
  janitor::clean_names() |>
  sf::st_set_crs(27572) |>
  tibble::as_tibble() |>
  sf::st_as_sf()

# Save using usethis
usethis::use_data(guerry, overwrite = TRUE)

testthat::test_that("rda is ASCII", {
  g <- tools::checkRdaFiles("data/guerry.rda")[["ASCII"]]
  testthat::expect_true(g)
})

#> ── Failure (Line 3): rda is ASCII ──────────────────────────────────────────────
#> `g`  is not TRUE
#> 
#> `actual`:   FALSE
#> `expected`: TRUE 

# Save using `save()`

save(guerry, file = "data/guerry.rda", ascii = TRUE)

testthat::test_that("rda is ASCII", {
  g <- tools::checkRdaFiles("data/guerry.rda")[["ASCII"]]
  testthat::expect_true(g)
})

#> Test passed πŸ˜€

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions