[R-pkg-devel] Minimizing package size containing Shiny app > 5 Mb

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Wed May 25 21:31:13 CEST 2022


On Wed, 25 May 2022 13:01:12 -0400
Jarrett Phillips <phillipsjarrett1 using gmail.com> wrote:

> The app contains a number of DNA FASTA files (.fas format) in the www
> folder, taking up only 1.2 Mb of space. The rest of the content in
> this folder is images.
> 
> I don't think I can compress the files (as per the Writing R
> Extensions text) since they are needed by the app when a user selects
> a particular file from a drop-doen menu.

Perhaps you could use gzfile() or xzfile() instead of file() when
opening the FASTA files in your application code? Or is it the case that
you have to pass the path to the uncompressed file to some kind of
library code that requires seeking file access, not just streaming
access?

Are there any gains from re-compressing the images? Depending on what
you're starting with, it might be possible to do losslessly. See e.g.
http://optipng.sourceforge.net/ https://pmt.sourceforge.io/pngcrush/

> I could ask for an exemption, but I've read from Hadley Wickham's R
> Packages book that this hasn't been too successful in recent years.

When in doubt, consult the official source: the CRAN policy.
https://cran.r-project.org/web/packages/policies.html

It does place a limit on the data size (5 MB) (although packages with
bigger total installed size do exist on CRAN (e.g. oce, which is
admittedly painful to maintain for various reasons)), but it also
suggests a way out: you could place the extra data in a data-only
package which would live elsewhere, for example, in a drat
https://dirk.eddelbuettel.com/code/drat.html repository on GitHub.

-- 
Best regards,
Ivan



More information about the R-package-devel mailing list