Example: I can load the same files folder using tm, in this way:
> library(tm)
Carico il pacchetto richiesto: NLP
> cname <- file.path("~", "Desktop", "texts")
> cname
[1] "~/Desktop/texts"
> dir(cname)
[1] "BIN 2017 1.txt" "BIN 2017 2.txt" "BIN 2017 3.txt" "BIN 2017 4.txt" "BIN 2018 1.txt" "BIN 2018 2.txt"
> docs <- VCorpus(DirSource(cname))
> summary(docs)
Length Class Mode
BIN 2017 1.txt 2 PlainTextDocument list
BIN 2017 2.txt 2 PlainTextDocument list
BIN 2017 3.txt 2 PlainTextDocument list
BIN 2017 4.txt 2 PlainTextDocument list
BIN 2018 1.txt 2 PlainTextDocument list
> inspect(docs)
<<VCorpus>>
Metadata: corpus specific: 0, document level (indexed): 0
Content: documents: 32
And then I can analyze it.
I would like to do the same thing using quanteda, but it doesn't work:
> library(readtext)
> DATA_DIR <- system.file("extdata/", package = "readtext")
> DATA_DIR <- system.file("~", "Desktop", "texts")
> (rt1 <- readtext(DATA_DIR/*))
Errore: unexpected '*' in "(rt1 <- readtext(DATA_DIR/*"
> library(readtext)
> DATA_DIR <- system.file("extdata/", package = "readtext")
> DATA_DIR <- system.file("~", "Desktop", "texts")
> (rt1 <- readtext(paste0(DATA_DIR, "/txt/texts/*")))
Error in list_files(file, ignore_missing, TRUE, verbosity) :
File '' does not exist.
>
I looked for tutorials and examples, but the examples concern URL, not folders on disk: https://cran.r-project.org/web/packages/quanteda/vignettes/quickstart.html.