Introduction

R is a language that is typically used for data analysis and visualization and statistical computing, however that doesn’t mean it can’t also be fun.


Simple Toys

Two super simple yet code-enhancing (in my personal opinion) packages that I have found are beepr and praise. Both are named in a way that is self-explanatory to what they do, but I will go through them and introduce the nuances to each.

praise Documentation


https://github.com/rladies/praise

praise()
## [1] "You are breathtaking!"


Practical Use

beepr

beepr contains two functions that can be triggered to produce a noise.

beep() will trigger when the line of code is run, and can be used for a variety of reasons.

Most notably, if you are running a chunk that requires a significant amount of time to process, beep() can be used to let you know once it has finished. It is a nice quality-of-life function that allows you to work on other things, or even walk away from your computer while the code is processing, without worrying about wasting time not knowing when your chunk has finished running.

The second function, beep_on_error() is used in much the same way, but will only trigger if an error is thrown in the desired expression. While beep() can accept up to two arguments, with both (technically) being optional, beep_on_error() takes on those two arguments, expr and sound, where only sound is optional.


praise

praise is a package that, while not necessarily needed for coding, can help when a project is particularly frustrating.

praise() is another simple function, this time one that will provide a random message of encouragement. I find this one especially useful when I am struggling to work out a coding problem; encouragement helps motivate, so throwing the occasional praise() into my code while I’m working helps me continue and work through the issues, rather than being tempted to give up.


Here’s where the fun begins!

beepr

One of the arguments that beep() accepts is to change the sound that is played. With 11 different included sounds there are so many to choose from!

  1. "ping"
  2. "coin"
  3. "fanfare"
  4. "complete"
  5. "treasure"
  6. "ready"
  7. "shotgun"
  8. "mario"
  9. "wilhelm"
  10. "facebook"
  11. "sword"

Each number above corresponds to the sound listed, so beep(3) will play the built-in fanfare (which happens to be the LoZ fanfare.

beep(3)
#this can also be written as beep("fanfare") for the same effect

You can also have a random sound played by using a sound argument that does not match the above.

beep(0)

My personal favorite aspect though is of course the customization! You can use any valid path to a .wav file or a valid http url to play your own custom sounds. This opens a whole new array of madness, allowing music, video game sounds, or even recordings you have created; so long as the path is valid, the opportunities are endless!

beep(path)


praise

Despite being a simple function, praise supports different “parts of speech”, allowing for message customization: "adjective" "adverb" "adverb_manner" "created" "creating" "exclamation" "rpackage"

praise("${Exclamation}! Check out this ${created} ${rpackage}!")
## [1] "Mmm! Check out this made R package!"
praise("I love ${creating} praise templates, they are so ${ADVERB} and ${Adverb_manner} ${adjective}! ${EXCLAMATION}!!")
## [1] "I love organizing praise templates, they are so RAPIDLY and Kindly superior! AWW!!"


You will notice that the capitalization that you use in the code is transferred to the output as well, allowing you to capitalize the first letter of the random word, capitalize the entire word, or leave it in all lowercase.

While it might not be as exciting as the sounds in beepr

praise("I find praise to be just as ${adjective}! ${EXCLAMATION}!!")
## [1] "I find praise to be just as polished! GEE!!"

Now, go forth and have fun!