readtext
readtext copied to clipboard
Providing path examples in vignettes
[Not sure whether it's 'kosher' to make suggestions for the documentation in github issues, but trying anyway] The documentation of quanteda (and readtext) is impressive. But there are often small things that may be obvious to many more experienced users, but can be terribly frustrating for beginners. The vignettes nicely illustrate various use cases for types of files; but not for different locations - they all use DATA_DIR. [The doc says that "When reading in custom text files, you will need to determine your own data directory (see ?setwd()).", but I'm still looking for that as I write this[. But so maybe you could some different PATH use cases throughout your vignettes? For a Windows user wanting to read in one (very large) json file that's in a shared Google drive folder (what to use instead of paste0 then?); for a Mac user who wants to read a folder of txt files from one of their local folders; etc. Just a suggestion!
Good suggestions, thanks. You're talking about familiarity with the command line and how operating systems provide file locations, but we could provide examples for Windows and other operating systems.
Yes! I am a beginning programmer and would appreciate examples in the vignette with local pathnames in Mac, and Windows.
Ok, I figured this out. The key is simply to:
DATA_DIR <- getwd()
for local path.
Then
rt_2 <- readtext(paste0(DATA_DIR, "/*.docx")) [for example]
Incidentally, you need the forward slash "/*.docx"; if you omit it, this happens:
rt_2 <- readtext(paste0(DATA_DIR, "*.docx"))
Error in list_files(file, ignore_missing, TRUE, verbosity) : File '' does not exist.
This is probably obvious to everyone except beginning programmers like myself; I post here in case it helps them.