8

I have a couple of text files that I want to include for examples in my documentation of data cleaning, however, when I include the text files in my 'data' file, I get an error from R CMD check saying that the package "cannot be installed", whereas if I don't include it, the package can be installed but it gives me an error saying that it the examples do not work because it can't find the text files (of course). Is there a way around this?

user2407894
  • 427
  • 1
  • 4
  • 10

1 Answers1

10

Building on @Tyler Rinker's comment, I think the proper place to include miscellaneous files is to include them in a inst/ directory in the package directory. From Section 5.1 of http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf, we get:

'inst/' for miscellaneous other stuff. The contents of this directory are completely copied to the installed version of a package.

This means that you would be able to get the text file using code like the following:

readLines(file = paste0(path.package("yourpackage"), "/your_text_file.txt"))
Alex
  • 15,186
  • 15
  • 73
  • 127
  • better use `system.file` than `path.package` : This tells more: https://stackoverflow.com/questions/13463103/inst-and-extdata-folders-in-r-packaging – moodymudskipper Sep 23 '21 at 14:31