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?
Importing using fread() It is part of the data. table package, which you will need to install. The fread() command is simpler to use because it tries to guess the format of the data in the file.
R can read data from a variety of file formats—for example, files created as text, or in Excel, SPSS or Stata. We will mainly be reading files in text format . txt or . csv (comma-separated, usually created in Excel).
R packages contain code, data, and documentation in a standardised collection format that can be installed by users of R, typically via a centralised software repository such as CRAN (the Comprehensive R Archive Network).
extdata: Extra data used to calculate ID numbers in Yassai et al.'s nomenclature.
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"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With