Closed SHAESEN2 closed 1 year ago
So if you have one file, does it make more sense to use/exchange it as-is? Just a thought 🤔
Alternatively, you could build an R package for it, which (I know) is a huge ask sometimes... but that will almost surely make it more than two or three files.
It makes sense for experimentation and training purposes. If you are not inclined to add a few lines of code to fix the issue, could you consider adding an informative message or documenting the behavior?
Hmm, good question, but after some rethinking, I'm still going to say no, and here is my reasoning:
usethis::create_package()
that creates a proper package will create more than one file.Thanks for bringing this up, though!
When packing only one file, I get an error that I traced back to the following piece of code:
idx_content_end <- c(idx_pkg[2L:nblocks] - 2L, nlines)
This line of code identifies the end of each block. If you have three files packed in the .txt file it will look for:
When you only pack one file, this logic does not work because nblocks is 1.
This can be solved by eg
if (nblocks == 1) { idx_content_end <- c(nlines) } else if (nblocks>1) { idx_content_end <- c(idx_pkg[2L:nblocks] - 2L, nlines) }
It would be good to include a unit test for this.