Get or set global options affecting functions across readtext.

readtext_options(..., reset = FALSE, initialize = FALSE)

Arguments

...

options to be set, as key-value pair, same as options. This may be a list of valid key-value pairs, useful for setting a group of options at once (see examples).

reset

logical; if TRUE, reset all readtext options to their default values

initialize

logical; if TRUE, reset only the readtext options that are not already defined. Used for setting initial values when some have been defined previously, such as in `.Rprofile`.

Value

When called using a key = value pair (where key can be a label or quoted character name)), the option is set and TRUE is returned invisibly.

When called with no arguments, a named list of the package options is returned.

When called with reset = TRUE as an argument, all arguments are options are reset to their default values, and TRUE is returned invisibly.

Details

Currently available options are:

verbosity

Default verbosity for messages produced when reading files. See readtext.

Examples

# save the current options (opt <- readtext_options())
#> $verbosity #> [1] 1 #>
# set higher verbosity readtext_options(verbosity = 3) # read something in here if (!interactive()) pkgload::load_all()
#> Loading readtext
DATA_DIR <- system.file("extdata/", package = "readtext") readtext(paste0(DATA_DIR, "/txt/UDHR/*"))
#> Reading texts from /Users/stefan/GitHub/readtext/inst/extdata/txt/UDHR/*
#> , using glob pattern
#> ... reading (txt) file: /Users/stefan/GitHub/readtext/inst/extdata/txt/UDHR/UDHR_chinese.txt
#> ... reading (txt) file: /Users/stefan/GitHub/readtext/inst/extdata/txt/UDHR/UDHR_czech.txt
#> ... reading (txt) file: /Users/stefan/GitHub/readtext/inst/extdata/txt/UDHR/UDHR_danish.txt
#> ... reading (txt) file: /Users/stefan/GitHub/readtext/inst/extdata/txt/UDHR/UDHR_english.txt
#> ... reading (txt) file: /Users/stefan/GitHub/readtext/inst/extdata/txt/UDHR/UDHR_french.txt
#> ... reading (txt) file: /Users/stefan/GitHub/readtext/inst/extdata/txt/UDHR/UDHR_georgian.txt
#> ... reading (txt) file: /Users/stefan/GitHub/readtext/inst/extdata/txt/UDHR/UDHR_greek.txt
#> ... reading (txt) file: /Users/stefan/GitHub/readtext/inst/extdata/txt/UDHR/UDHR_hungarian.txt
#> ... reading (txt) file: /Users/stefan/GitHub/readtext/inst/extdata/txt/UDHR/UDHR_icelandic.txt
#> ... reading (txt) file: /Users/stefan/GitHub/readtext/inst/extdata/txt/UDHR/UDHR_irish.txt
#> ... reading (txt) file: /Users/stefan/GitHub/readtext/inst/extdata/txt/UDHR/UDHR_japanese.txt
#> ... reading (txt) file: /Users/stefan/GitHub/readtext/inst/extdata/txt/UDHR/UDHR_russian.txt
#> ... reading (txt) file: /Users/stefan/GitHub/readtext/inst/extdata/txt/UDHR/UDHR_vietnamese.txt
#> ... read 13 documents.
#> readtext object consisting of 13 documents and 0 docvars. #> # data.frame [13 × 2] #> doc_id text #> <chr> <chr> #> 1 UDHR_chinese.txt "\"世界人权宣言\n联合国\"..." #> 2 UDHR_czech.txt "\"VŠEOBECNÁ \"..." #> 3 UDHR_danish.txt "\"Den 10. de\"..." #> 4 UDHR_english.txt "\"Universal \"..." #> 5 UDHR_french.txt "\"Déclaratio\"..." #> 6 UDHR_georgian.txt "\"FLFVBFYBC \"..." #> # ... with 7 more rows
# reset to saved options readtext_options(opt)