I am creating a package that contains one function, which randomly samples an image (meme) and displays it on the RStudio Viewer pane (see readme file on the github repo).
Two questions:
The package works locally but fails once it’s installed. It displays the error on the screenshot attached, which to my understanding could imply that the function is not sourcing the images correctly. Please help me out here.
I have a list of 145 images totalling to 52 mb (the package has like 10 for now). I noticed that the package is taking too long to install with the 145 images. Is there a work around on this? Or do I just have to work with a small number of images? Or is the package taking too long to install because of a different issue?
where the full.names argument ensures you won’t need the paste0() for this other line as the path will be already complete.
meme_moja <- image_read(picha)
Using system.file() will ensure that the images can be found when the package is installed… but also when it is loaded with devtools because devtools uses pkgload for loading, that has “shimmed” version of system.file() cf Load complete package — load_all • pkgload (I had forgotten the word “shim” until right now ).
Just a small note, next time would you mind copy-pasting the code instead of a screenshot? Thanks
Thanks @maelle . The issue here is the images are being used to create the rKenyaMemes package. The entertain_me() function should source the files, randomly pick one and display it on the Viewer pane. So every time someone runs entertain_me(), a different image should be displayed.
Noted on the code-sharing part. I will avoid screenshots. Thanks
Wow!!! It works… Thank you for your assistance … and I am glad that you were entertained. A majority of the memes are in our local language but a few are in english. Do you know how I would go about the second question?
I have a list of 145 images totalling to 52 mb (the package has like 10 for now). I noticed that the package is taking too long to install with the 145 images. Is there a work around on this? Or do I just have to work with a small number of images? Or is the package taking too long to install because of a different issue?
I am not sure whether the size of the package influences its installation time but it might take longer to download it for sure. Maybe, if it’s ok for the package to only work when there’s an internet connection, it could rely on hosting the images somewhere else and either download one / try to show the remote image in the viewer pane (however that second idea didn’t work for me locally, I had a quick look at https://support.rstudio.com/hc/en-us/articles/202133558-Extending-RStudio-with-the-Viewer-Pane). If the images are hosted somewhere else the challenge will be to make sure the image list in the package is up-to-date with what’s hosted somewhere else.
Hosted somewhere else might be a Netlify website for instance. By the way I have no idea what legal implications there are to re-sharing memes. Is there an API for Kenyan memes or do you have to build it?
Thank you for the information. I do not think that are any legal implications with meme sharing since they are freely shared online and circulate amongst us freely, and given that I am not earning anything from this package, I think I am safe…but let’s wait and see if any issue arises.
I am currently installing the package with the 145 images to see the download time…then I’ll know how to move on from there. Thank you for making my Friday amazing.
The package is taking about 11 minutes to install on my laptop so yeah, I will need to look for a way to move the memes to an API and call them from there. Thanks again Maelle.
I’m guessing you don’t need a full API, just a static website with all the images (and somewhere else a list of all the URL / using a sitemap as list of URLs) but just in case, as your website is Hugo, I’m posting this link: Build a JSON API With Hugo's Custom Output Formats | Forestry.io