Procrastination in R: Cowsay Package

cat

Today, I’d like to share a package I use frequently and thoroughly enjoy. When someone asks me what I am learning in school and my laptop is handy, I like to impress them by punching it in. Much of the following information I got from a blog post by Ista Zahn, a Data Science Specialist at Harvard (2016).

“Cowsay” was originally created long ago in Linux. It allows you to generate ASCII animals. You can also create customized quotes for them. Here is the package you need (adapted for R by Chamberlain, et al., n.d) and the code for the kitty I made above.

install.packages(cowsay)

library(cowsay

say(“Hi, welcome to the Rstatz blog!!!”)

You can also refer to specific animals, in this case, I have chosen a cow.

say(“MU”, by = “cow”)

cow

The next example may appeal to the part of you that misses Clippy sometimes when you are hopelessly stuck while coding (not that Clippy ever helped anybody).

say(“Hi I’m Clippy, it looks like you’re making some dataframes. Would you like some help with that?”)

clippy

Below you can view all of the available pictures. (Note: Several of them do not work if you are using a Windows computer due to the characters used; these include anxiouscat, fish, grumpycat, longcat, longtailcat, mushroom, shortcat, signbunny, and stretchycat, but they will appear on a Mac).

sort(names(animals))

sortnames

This one will print a horse with neverending legs. I’m pretty sure the legs keep growing forever until you stop the output. This is a good one to put on your study buddy’s computer if they walk away for a minute.

endless_horse()

horse

This is my personal favorite. This function (created by Zahn) will generate a random animal to say hello.

someone_say_hello = function() {animal = sample(names(animals), 1)

say(paste(“Hello, I’m a “, animal, “.”, collapse = “”), by = animal)}

someone_say_hello()

spider

Next time you are burnt out on studying, I hope this will serve to brighten your day!

References

Chamberlain, S., Rinker, T., Leeper, T., Ross, N., FitzJohn, R., Gotanda, K., . . . , Boersch-Supan, P. (n.d.). Cowsay w/ more animals, in R. Retrieved from https://github.com/sckott/cowsay

Zahn, I. (June 20, 2016). Useless but fun R packages [Blog post]. Retrieved from http://people.fas.harvard.edu/~izahn/posts/useless-but-fun-r-packages/ Accessed 18 Oct. 2017.