Introduction
I am happy to share a fun project I put together this weekend - a new R package called dundermifflin
. If you can’t guess from the name, it will give you quotes from the Office whenever you want! This package was inspired by the goodshirt
package, which gives users quotes from The Good Place, I was able to great a similar package for the Office. By using theOffice-api
, I created a data set, office_quotes
, that is shipped with the package, that has every line from the Office, with the exception of season 5.
I will try to keep this brief, because as in the words of Kevin:
So let’s dive right in!
To install the packages you can use remotes::install_github
:
remotes::install_github("tbradley1013/dundermifflin")
library(dundermifflin)
library(cowsay)
library(magrittr)
Getting quotes
The implementation of this package is pretty straight forward. There main function of this package is get_quote
and this will return a random quote from any season and episode in the show. By default the quotes are required to have a minimum of 10 words and a maximum of 100. This is to try to remove some of the meaningless lines from the show, but it will likely also miss some of the great one-liners. See the Next Steps section for how I hope to deal with this! This function also allows you to specify the season, episode number, episode name, scene number, or character name to narrow down the quotes you get. By default, only quotes by characters that are apart of the main office staff are included. Let’s see how it works.
get_quote()
## Good morning, Vietnam! Okay. You know what? This isn't working. Because um I'm not nervous in front of them. They're my subordinates.
## ~ Dwight
## Season 2, Epsiode 17 - Dwight's Speech
get_quote(season = 1)
## Yeah, well, if you leave we'll only have two left. Yes. Enjoy. Absolutely. Namaste. Ok, well since I am leading this, let's get down to business and why don't I just kind of introduce myself, OK? Um. I am Michael and I am part English, Irish, German and Scottish. Sort of a virtual United Nations. But what some of you might not know is that I am also part Native American Indian.
## ~ Michael
## Season 1, Epsiode 2 - Diversity Day
get_quote(character = "Michael")
## What if Pam was a lesbian? What if she brought her "partner" in to work? Would that be crossing the line?
## ~ Michael
## Season 2, Epsiode 2 - Sexual Harassment
By default, get_quote
and all the other function variants, to be discussed in later sections, return an object of class dunder
. This is just a tbl
with info for one quote. This object can be passed to as.character
and then used in conjunction with cowsay::say
.
get_quote() %>%
as.character() %>%
say()
## Colors cannot be applied in this environment :( Try using a terminal or RStudio.
##
## --------------
## Hey, everybody. I don't know who you haven't met yet, but I think this is one of them. This is my girlfriend - Carol. This is just the front of her. Show 'em, show 'em the other side.
## ~ Michael
## Season 3, Epsiode 10 - A Benihana Christmas
## --------------
## \
## \
## \
## |\___/|
## ==) ^Y^ (==
## \ ^ /
## )=*=(
## / \
## | |
## /| | | |\
## \| | |_|/\
## jgs //_// ___/
## \_)
##
Quotes by Character
While you can specify the character you wish to receive quotes from in the get_quote
function. There are also functions for all of the main characters! Sorry if I missed any, but:
The character functions are super straightforward. Any of the arguments, except character
, for get_quote
can be passed to them. Here are some examples:
michael()
## Love that Andy, right? Solid fellow. Seems smart enough. Likes me a lot. A lot. Too much. Like a crazy person. A little. Not super crazy... just... there's something about him that creeps me out. I can't really explain it. He's always up in my bidness. Which is ebonics for "being in my face and annoying the bejesus out of me." I don't understand how someone could have so little self-awareness.
## ~ MIchael
## Season 3, Epsiode 13 - The Return
jim()
## Can I just have the ham and cheese sandwich, thanks.
## ~ Jim
## Season 2, Epsiode 13 - The Secret
dwight()
## You just need to realize that so much rides on this. You have no idea.
## ~ Dwight
## Season 8, Epsiode 17 - Test the Store
kevin()
## Yeah. But not just the cookies, though. That was just a 'for instance.'
## ~ Kevin
## Season 8, Epsiode 8 - Gettysburg
Quotes by Department
You can also get quotes for entire departments.
sales()
## And you make sure to get down there and check out that Harry Potter World.
## ~ Dwight
## Season 7, Epsiode 17 - Todd Packer
accounting()
## No. I'm fine. Okay, from here now. The first lesson that I'm gonna teach you, right, is about finding success. And the key to finding success is to picture a winner.
## ~ Kevin
## Season 7, Epsiode 13 - The Seminar
reception()
## Okay. Um... here it is. Don't put your fingers in there. Cool huh?
## ~ Pam
## Season 2, Epsiode 18 - Take Your Daughter to Work Day
That’s what she said
This one might be a little more taboo, but since it is a memorable running joke of the show, I created a function she_said
that returns a random “That’s what she said” joke from the office. This function will return the line before the joke and the line with the
joke.
she_said()
## Michael: I mean, they're just dough twisted up with some candy. They taste so good in my mouth.
## Stanley: That's what she said. [Stanley and Michael both laugh]
## Season 3, Epsiode 5 - Initiation
Start your day (read: R session) with the Office
You can also add these functions to your .Rprofile
so that you start every new R session with a quote from the office!
Next Steps
Currently, these functions will return a random quote from the entire show script that meet certain length requirements. While a lot of them are hysterical (I have run the function a lot and enjoyed it immensely), you will certainly get some quotes that are not. Something I would like to do is create a separate data set that contains specific quotes that I (and you!) find especially funny, and you can help!. There is an argument in the get_quote
function, idx
, that can be set to TRUE
that will return the “Quote Index”. What you can do is use this argument and submit the quote, along with the index, to this github issue as a comment. I will work periodically to add all of the funny ones to a new data set that will provide users with a more curated quote output to make sure you are always getting the funniest quotes possible!