quanteda / readtext

an R package for reading text files
https://readtext.quanteda.io
120 stars 28 forks source link

readtext::readtext() fails if package has not been loaded #123

Closed kbenoit closed 6 years ago

kbenoit commented 6 years ago

This is because zzz.R has not run .onload() yet to set the options.

R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[R.app GUI 1.70 (7507) x86_64-apple-darwin15.6.0]

[Workspace restored from /Users/kbenoit/.RData]
[History restored from /Users/kbenoit/.Rapp.history]

> DATA_DIR <- system.file("extdata/", package = "readtext")
> rt1 <- readtext::readtext(paste0(DATA_DIR, "txt/UDHR/*"))
Error in if (getOption("readtext_verbosity") >= 3) message(", using glob pattern") : 
  argument is of length zero
jeroen commented 6 years ago

Update: this bug still exists in the new release. To reproduce run in a clean R session:

DATA_DIR <- system.file("extdata", "pdf", "UDHR", package = "readtext")
readtext::readtext(sort(list.files(DATA_DIR, full.names = TRUE, pattern = "\\.pdf$")))
amatsuo commented 6 years ago

@jeroen Thanks for the feedback. Should be fixed when a PR is accepted.

kbenoit commented 6 years ago

It’s fixed now, and I added a more comprehensive approach that allows more options to be added. It works in the same as as quanteda::quanteda_options(), which can be set in .Rprofile for instance but will always be initialized if called without the package being attached.

Will re-submit to CRAN asap.