tinieR 0.4.1

[This article was first published on R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I got really, really bored this week, so I decided to go back to the R package, tinieR, that I released last year (if you haven’t seen it before, tinieR shrinks image file sizes using the TinyPNG.com API). My idle tinkering ended up with a few cool little additions to the package, so I figured it was time for a new release: v0.4.1!

Why 0.4.1? Because I set it all up to be 0.4.0, but then I wasn’t entirely happy with some things and kept tinkering, and didn’t realise that it wasn’t exactly straightforward to change git release/tag options. So .1 it is…

New things

Here are the main additions to the package:

  • Added ability to set global defaults for tinify() arguments with tinify_defaults(). Changes made are printed to the console, and if called without any arguments, prints all current default settings.
  • Added new suffix argument in tinify() to change the “_tiny” suffix applied to tinified file names.
  • Added new return_path = "proj" option to return_path argument in tinify() to return the path to the newly tinified file relative to the project directory, no matter the current working directory.

You can read more in the new package vignette here.

Useful things I learnt

Aside from being slightly useful, the main reason I work on tinieR is to give me an excuse to poke around in R and learn new things about the language. So what did this latest round of tinkering show me?

  • tinify_defaults() really taught me about how to set and retrieve options in R, and in particular, how useful it is that they have a default argument to fall back on when not set.
  • It also taught me more about returning messages and warnings in R, how to suppress warnings when required, and how to use tryCatch to collect errors and supply my own or perform a new action.
  • …And how to deal with storing, setting, and retrieving these default options for use in package tests (using on.exit() mostly).
  • I didn’t end up actually using it (yet), but I also found out about the crayon package for printing coloured text to the R console – fun!
  • The new "proj" setting for return_path got me familiar with the rprojroot package. I’d used it before for… something that I forget, but it was great to really spend some time poking around in it. It’s a very useful package when you need it!
  • I wrote my first vignette, and it was interesting to see how the usethis package and my prior experience with Rmarkdown made it exceptionally easy.
  • Not directly for the release of 0.4.1, but I also spent some time tinkering with the pkgdown configuration for the package documentation site. Nothing drastic, just a new theme and some moving around of contents, but good to know!

I really recommend developing a package for getting to know R better. It doesn’t have to do much fancy – tinieR certainly doesn’t – but having problems to solve really gives purpose to your learning. If you want to try it, check out the R Packages book by Hadley Wickham and Jenny Bryan for a complete guide!

I hope you’ll try out tinieR for yourself – and if you encounter any issues, please let me know!

To leave a comment for the author, please follow the link and comment on their blog: R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)